misc/libphyslayer/CMakeLists.txt
author Simon McVittie <smcv@debian.org>
Mon, 12 Sep 2022 10:40:53 -0400
branch1.0.0
changeset 15859 7b1d6dfa3173
parent 12124 ffc7bb9fde01
child 15738 027a56b3895e
permissions -rw-r--r--
Remove FindSDL2 find-module, use sdl2-config.cmake instead This requires SDL >= 2.0.4. Since <https://bugzilla.libsdl.org/show_bug.cgi?id=2464> was fixed in SDL 2.0.4, SDL behaves as a CMake "config-file package", even if it was not itself built using CMake: it installs a sdl2-config.cmake file to ${libdir}/cmake/SDL2, which tells CMake where to find SDL's headers and library, analogous to a pkg-config .pc file. As a result, we no longer need to copy/paste a "find-module package" to be able to find a system copy of SDL >= 2.0.4 with find_package(SDL2). Find-module packages are now discouraged by the CMake developers, in favour of having upstream projects behave as config-file packages. This results in a small API change: FindSDL2 used to set SDL2_INCLUDE_DIR and SDL2_LIBRARY, but the standard behaviour for config-file packages is to set <name>_INCLUDE_DIRS and <name>_LIBRARIES. Use the CONFIG keyword to make sure we search in config-file package mode, and will not find a FindSDL2.cmake in some other directory that implements the old interface. In addition to deleting redundant code, this avoids some assumptions in FindSDL2 about the layout of a SDL installation. The current libsdl2-dev package in Debian breaks those assumptions; this is considered a bug and will hopefully be fixed soon, but it illustrates how fragile these assumptions can be. We can be more robust against different installation layouts by relying on SDL's own CMake integration. When linking to a copy of CMake in a non-standard location, users can now set the SDL2_DIR or CMAKE_PREFIX_PATH environment variable to point to it; previously, these users would have used the SDL2DIR environment variable. This continues to be unnecessary if using matching system-wide installations of CMake and SDL2, for example both from Debian.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15859
7b1d6dfa3173 Remove FindSDL2 find-module, use sdl2-config.cmake instead
Simon McVittie <smcv@debian.org>
parents: 12124
diff changeset
     1
find_package(SDL2 REQUIRED CONFIG)
8526
9f2bd885d773 update cmake files to use the two libraries independently
koda
parents:
diff changeset
     2
15859
7b1d6dfa3173 Remove FindSDL2 find-module, use sdl2-config.cmake instead
Simon McVittie <smcv@debian.org>
parents: 12124
diff changeset
     3
include_directories(${SDL2_INCLUDE_DIRS})
8526
9f2bd885d773 update cmake files to use the two libraries independently
koda
parents:
diff changeset
     4
include_directories(${PHYSFS_INCLUDE_DIR})
9f2bd885d773 update cmake files to use the two libraries independently
koda
parents:
diff changeset
     5
include_directories(${LUA_INCLUDE_DIR})
9f2bd885d773 update cmake files to use the two libraries independently
koda
parents:
diff changeset
     6
9270
a9b9ebd3d3be frontend compiles
koda
parents: 9225
diff changeset
     7
8526
9f2bd885d773 update cmake files to use the two libraries independently
koda
parents:
diff changeset
     8
set(PHYSLAYER_SRCS
9991
3858d99476f5 add compatibility for physicsfs 2.0
sheepluva
parents: 9650
diff changeset
     9
    physfscompat.c
8526
9f2bd885d773 update cmake files to use the two libraries independently
koda
parents:
diff changeset
    10
    physfsrwops.c
9f2bd885d773 update cmake files to use the two libraries independently
koda
parents:
diff changeset
    11
    physfslualoader.c
9f2bd885d773 update cmake files to use the two libraries independently
koda
parents:
diff changeset
    12
    hwpacksmounter.c
9f2bd885d773 update cmake files to use the two libraries independently
koda
parents:
diff changeset
    13
)
9f2bd885d773 update cmake files to use the two libraries independently
koda
parents:
diff changeset
    14
9202
4d69569baabb also physlayer can be comiled as static or shared now
koda
parents: 8526
diff changeset
    15
#compiles and links actual library
4d69569baabb also physlayer can be comiled as static or shared now
koda
parents: 8526
diff changeset
    16
add_library (physlayer ${PHYSLAYER_SRCS})
12124
ffc7bb9fde01 Adopt some patches from OpenBSD port
unc0rr
parents: 11659
diff changeset
    17
set_target_properties(physlayer PROPERTIES
ffc7bb9fde01 Adopt some patches from OpenBSD port
unc0rr
parents: 11659
diff changeset
    18
                          VERSION 1.0
ffc7bb9fde01 Adopt some patches from OpenBSD port
unc0rr
parents: 11659
diff changeset
    19
                          SOVERSION 1.0)
15859
7b1d6dfa3173 Remove FindSDL2 find-module, use sdl2-config.cmake instead
Simon McVittie <smcv@debian.org>
parents: 12124
diff changeset
    20
target_link_libraries(physlayer ${SDL2_LIBRARIES} lua physfs)
9202
4d69569baabb also physlayer can be comiled as static or shared now
koda
parents: 8526
diff changeset
    21
install(TARGETS physlayer RUNTIME DESTINATION ${target_binary_install_dir}
4d69569baabb also physlayer can be comiled as static or shared now
koda
parents: 8526
diff changeset
    22
                          LIBRARY DESTINATION ${target_library_install_dir}
4d69569baabb also physlayer can be comiled as static or shared now
koda
parents: 8526
diff changeset
    23
                          ARCHIVE DESTINATION ${target_library_install_dir})
4d69569baabb also physlayer can be comiled as static or shared now
koda
parents: 8526
diff changeset
    24
get_target_property(physlayer_fullpath physlayer LOCATION)
8526
9f2bd885d773 update cmake files to use the two libraries independently
koda
parents:
diff changeset
    25
9f2bd885d773 update cmake files to use the two libraries independently
koda
parents:
diff changeset
    26
9f2bd885d773 update cmake files to use the two libraries independently
koda
parents:
diff changeset
    27
## added standard variables (FORCE or cmake won't pick 'em)
9202
4d69569baabb also physlayer can be comiled as static or shared now
koda
parents: 8526
diff changeset
    28
set(PHYSLAYER_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE STRING "Physlayer include dir" FORCE)
4d69569baabb also physlayer can be comiled as static or shared now
koda
parents: 8526
diff changeset
    29
set(PHYSLAYER_LIBRARY ${physlayer_fullpath} CACHE STRING "Physlayer library" FORCE)
8526
9f2bd885d773 update cmake files to use the two libraries independently
koda
parents:
diff changeset
    30
11659
71bdf987e41f Fully support emscripten toolchain in our build system
koda
parents: 11374
diff changeset
    31
if(BUILD_ENGINE_JS)
71bdf987e41f Fully support emscripten toolchain in our build system
koda
parents: 11374
diff changeset
    32
    set_target_properties(physlayer PROPERTIES SUFFIX ".bc")
71bdf987e41f Fully support emscripten toolchain in our build system
koda
parents: 11374
diff changeset
    33
endif()
71bdf987e41f Fully support emscripten toolchain in our build system
koda
parents: 11374
diff changeset
    34