File: SFMLConfig.cmake.in

package info (click to toggle)
libsfml 3.0.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,700 kB
  • sloc: cpp: 52,774; ansic: 24,944; objc: 668; sh: 172; xml: 25; makefile: 18
file content (181 lines) | stat: -rw-r--r-- 8,009 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# This script provides the SFML libraries as imported targets
# ------------------------------------
#
# Usage
# -----
#
# When you try to locate the SFML libraries, you must specify which modules you want to use (System, Window, Graphics, Network, Audio, Main).
# If none is given, no imported target will be created and you won't be able to link to SFML libraries.
# example:
#   find_package(SFML COMPONENTS Graphics Window System) # find the graphics, window and system modules
#
# You can enforce a specific version, either MAJOR.MINOR or only MAJOR.
# If nothing is specified, the version won't be checked (i.e. any version will be accepted).
# example:
#   find_package(SFML COMPONENTS ...)     # no specific version required
#   find_package(SFML 3 COMPONENTS ...)   # any 3.x version
#   find_package(SFML 3.0.2 COMPONENTS ...) # version 3.0.2 or greater with the same major version
#
# By default, the dynamic libraries of SFML will be found. To find the static ones instead,
# you must set the SFML_STATIC_LIBRARIES variable to ON before calling find_package(SFML ...).
# You don't need to deal with SFML's dependencies when linking your targets against SFML libraries,
# they will all be configured automatically, even if you use SFML static libraries.
# example:
#   set(SFML_STATIC_LIBRARIES ON)
#   find_package(SFML 3 COMPONENTS Network System)
#
# When searching for SFML with find_package(), keep in mind that it will also find versions which are
# in development (i.e. between two released versions), if you have them in your search path.
# If you want to make sure that a found SFML package corresponds to an official release, check the
# bool output variable SFML_VERSION_IS_RELEASE, which is true for official releases and false for development versions.
#
# On macOS by default CMake will search for frameworks. If you want to use static libraries and have installed
# both SFML frameworks and SFML static libraries, your must set CMAKE_FIND_FRAMEWORK to "NEVER" or "LAST"
# in addition to setting SFML_STATIC_LIBRARIES to ON. Otherwise CMake will check the frameworks bundle config and
# fail after finding out that it does not provide static libraries. Please refer to CMake documentation for more details.
#
# Additionally, keep in mind that SFML frameworks are only available as release libraries unlike dylibs which
# are available for both release and debug modes.
#
# If SFML is not installed in a standard path, you can use CMAKE_PREFIX_PATH to tell CMake in what directory
# SFML was installed.
#
# Output
# ------
#
# This script defines the following variables:
# - For each specified module XXX (System, Window, Graphics, Network, Audio, Main):
#   - SFML_XXX_FOUND:  true if either the debug or release library of the xxx module is found
# - SFML_FOUND:        true if all the required modules are found
#
# And the following targets:
# - For each specified module XXX (System, Window, Graphics, Network, Audio, Main):
#   - SFML::XXX
# The SFML targets are the same for both Debug and Release build configurations and will automatically provide
# correct settings based on your currently active build configuration. The SFML targets name also do not change
# when using dynamic or static SFML libraries.
#
# When linking against a SFML target, you do not need to specify indirect dependencies. For example, linking
# against SFML::Graphics will also automatically link against SFML::Window and SFML::System.
#
# example:
#   find_package(SFML 3 COMPONENTS Graphics Audio REQUIRED)
#   add_executable(myapp ...)
#   target_link_libraries(myapp PRIVATE SFML::Graphics SFML::Audio)

cmake_policy(VERSION 3.22...3.31)

if(NOT SFML_FIND_COMPONENTS)
    message(FATAL_ERROR "find_package(SFML) called with no component")
endif()

set(SFML_SUPPORTED_COMPONENTS Audio Graphics Main Network System Window)

foreach(component ${SFML_FIND_COMPONENTS})
    if(NOT component IN_LIST SFML_SUPPORTED_COMPONENTS)
        set(SFML_FOUND OFF)
        set(SFML_NOT_FOUND_MESSAGE "Unsupported SFML component: ${component}")
        message(FATAL_ERROR "${SFML_NOT_FOUND_MESSAGE}")
    endif()
endforeach()

set(SFML_DOC_PATH "/usr/share/doc/libsfml-dev")

# Update requested components (eg. request window component if graphics component was requested)
set(FIND_SFML_COMPONENTS_SORTED "")
if("Audio" IN_LIST SFML_FIND_COMPONENTS)
    list(APPEND FIND_SFML_COMPONENTS_SORTED "System" "Audio")
endif()
if("Graphics" IN_LIST SFML_FIND_COMPONENTS)
    list(APPEND FIND_SFML_COMPONENTS_SORTED "System" "Window" "Graphics")
endif()
if("Main" IN_LIST SFML_FIND_COMPONENTS)
    list(APPEND FIND_SFML_COMPONENTS_SORTED "Main")
endif()
if("Network" IN_LIST SFML_FIND_COMPONENTS)
    list(APPEND FIND_SFML_COMPONENTS_SORTED "System" "Network")
endif()
if("System" IN_LIST SFML_FIND_COMPONENTS)
    list(APPEND FIND_SFML_COMPONENTS_SORTED "System")
endif()
if("Window" IN_LIST SFML_FIND_COMPONENTS)
    list(APPEND FIND_SFML_COMPONENTS_SORTED "System" "Window")
endif()
list(REMOVE_DUPLICATES FIND_SFML_COMPONENTS_SORTED)

# Choose which target definitions must be imported
if(SFML_STATIC_LIBRARIES)
    set(SFML_IS_FRAMEWORK_INSTALL "@SFML_BUILD_FRAMEWORKS@")
    if(SFML_IS_FRAMEWORK_INSTALL)
        message(WARNING "Static frameworks are not supported by SFML. Clear cache entries, \
and either change SFML_STATIC_LIBRARIES or CMAKE_FIND_FRAMEWORK before calling find_package(SFML)")
    endif()
    set(config_name "Static")
else()
    set(config_name "Shared")
endif()

# Set SFML_FOUND to ON by default, may be overwritten by one of the includes below
set(SFML_FOUND ON)

# Only configure dependencies if we are static linking
if(SFML_STATIC_LIBRARIES)
    # Look for dependencies in "reverse order"
    # This is due to the fact that among other things, resolving the
    # X11 dependency will break our own find_package(Freetype CONFIG)
    # because X11 attempts to find Freetype itself to resolve its Xft dependency.
    set(FIND_SFML_COMPONENTS_REVERSED ${FIND_SFML_COMPONENTS_SORTED})
    list(REVERSE FIND_SFML_COMPONENTS_REVERSED)

    foreach(component ${FIND_SFML_COMPONENTS_REVERSED})
        set(dependencies_file "${CMAKE_CURRENT_LIST_DIR}/SFML${component}Dependencies.cmake")
        if(EXISTS "${dependencies_file}")
            include("${dependencies_file}")
        endif()
    endforeach()
endif()

foreach(component ${FIND_SFML_COMPONENTS_SORTED})
    string(TOUPPER "${component}" UPPER_COMPONENT)
    set(targets_config_file "${CMAKE_CURRENT_LIST_DIR}/SFML${component}${config_name}Targets.cmake")

    # Generate imported targets for SFML components
    if(EXISTS "${targets_config_file}")
        include("${targets_config_file}")

        if(TARGET SFML::${component})
            set(SFML_${UPPER_COMPONENT}_FOUND ON)
        else()
            set(SFML_${UPPER_COMPONENT}_FOUND OFF)
            set(SFML_FOUND OFF)
            if(SFML_FIND_REQUIRED_${component})
                set(FIND_SFML_ERROR "Found SFML but requested component '${component}' is missing in the package configuration.")
            endif()
        endif()
    else()
        set(FIND_SFML_ERROR "Requested SFML configuration (${config_name}) was not found")
        if(config_name STREQUAL "Shared")
            string(APPEND FIND_SFML_ERROR "\nSet SFML_STATIC_LIBRARIES to ON for static libraries")
        elseif(config_name STREQUAL "Static")
            string(APPEND FIND_SFML_ERROR "\nSet SFML_STATIC_LIBRARIES to OFF for shared libraries")
        endif()
        set(SFML_${UPPER_COMPONENT}_FOUND OFF)
        set(SFML_FOUND OFF)
    endif()
endforeach()

if(SFML_FOUND)
    set(SFML_VERSION_IS_RELEASE @VERSION_IS_RELEASE@)
else()
    if(SFML_FIND_REQUIRED)
        # fatal error
        message(FATAL_ERROR "${FIND_SFML_ERROR}")
    elseif(NOT SFML_FIND_QUIETLY)
        # error but continue
        message(STATUS "${FIND_SFML_ERROR}")
    endif()
endif()

if(SFML_FOUND AND NOT SFML_FIND_QUIETLY)
    message(STATUS "Found SFML @PROJECT_VERSION@ in ${CMAKE_CURRENT_LIST_DIR}")
endif()