1b877906bSopenharmony_ci 2b877906bSopenharmony_ciadd_library(glfw ${GLFW_LIBRARY_TYPE} 3b877906bSopenharmony_ci "${GLFW_SOURCE_DIR}/include/GLFW/glfw3.h" 4b877906bSopenharmony_ci "${GLFW_SOURCE_DIR}/include/GLFW/glfw3native.h" 5b877906bSopenharmony_ci internal.h platform.h mappings.h 6b877906bSopenharmony_ci context.c init.c input.c monitor.c platform.c vulkan.c window.c 7b877906bSopenharmony_ci egl_context.c osmesa_context.c null_platform.h null_joystick.h 8b877906bSopenharmony_ci null_init.c null_monitor.c null_window.c null_joystick.c) 9b877906bSopenharmony_ci 10b877906bSopenharmony_ci# The time, thread and module code is shared between all backends on a given OS, 11b877906bSopenharmony_ci# including the null backend, which still needs those bits to be functional 12b877906bSopenharmony_ciif (APPLE) 13b877906bSopenharmony_ci target_sources(glfw PRIVATE cocoa_time.h cocoa_time.c posix_thread.h 14b877906bSopenharmony_ci posix_module.c posix_thread.c) 15b877906bSopenharmony_cielseif (WIN32) 16b877906bSopenharmony_ci target_sources(glfw PRIVATE win32_time.h win32_thread.h win32_module.c 17b877906bSopenharmony_ci win32_time.c win32_thread.c) 18b877906bSopenharmony_cielse() 19b877906bSopenharmony_ci target_sources(glfw PRIVATE posix_time.h posix_thread.h posix_module.c 20b877906bSopenharmony_ci posix_time.c posix_thread.c) 21b877906bSopenharmony_ciendif() 22b877906bSopenharmony_ci 23b877906bSopenharmony_ciadd_custom_target(update_mappings 24b877906bSopenharmony_ci COMMAND "${CMAKE_COMMAND}" -P "${GLFW_SOURCE_DIR}/CMake/GenerateMappings.cmake" mappings.h.in mappings.h 25b877906bSopenharmony_ci WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" 26b877906bSopenharmony_ci COMMENT "Updating gamepad mappings from upstream repository" 27b877906bSopenharmony_ci SOURCES mappings.h.in "${GLFW_SOURCE_DIR}/CMake/GenerateMappings.cmake" 28b877906bSopenharmony_ci VERBATIM) 29b877906bSopenharmony_ci 30b877906bSopenharmony_ciset_target_properties(update_mappings PROPERTIES FOLDER "GLFW3") 31b877906bSopenharmony_ci 32b877906bSopenharmony_ciif (GLFW_BUILD_COCOA) 33b877906bSopenharmony_ci target_compile_definitions(glfw PRIVATE _GLFW_COCOA) 34b877906bSopenharmony_ci target_sources(glfw PRIVATE cocoa_platform.h cocoa_joystick.h cocoa_init.m 35b877906bSopenharmony_ci cocoa_joystick.m cocoa_monitor.m cocoa_window.m 36b877906bSopenharmony_ci nsgl_context.m) 37b877906bSopenharmony_ciendif() 38b877906bSopenharmony_ci 39b877906bSopenharmony_ciif (GLFW_BUILD_WIN32) 40b877906bSopenharmony_ci target_compile_definitions(glfw PRIVATE _GLFW_WIN32) 41b877906bSopenharmony_ci target_sources(glfw PRIVATE win32_platform.h win32_joystick.h win32_init.c 42b877906bSopenharmony_ci win32_joystick.c win32_monitor.c win32_window.c 43b877906bSopenharmony_ci wgl_context.c) 44b877906bSopenharmony_ciendif() 45b877906bSopenharmony_ci 46b877906bSopenharmony_ciif (GLFW_BUILD_X11) 47b877906bSopenharmony_ci target_compile_definitions(glfw PRIVATE _GLFW_X11) 48b877906bSopenharmony_ci target_sources(glfw PRIVATE x11_platform.h xkb_unicode.h x11_init.c 49b877906bSopenharmony_ci x11_monitor.c x11_window.c xkb_unicode.c 50b877906bSopenharmony_ci glx_context.c) 51b877906bSopenharmony_ciendif() 52b877906bSopenharmony_ci 53b877906bSopenharmony_ciif (GLFW_BUILD_WAYLAND) 54b877906bSopenharmony_ci target_compile_definitions(glfw PRIVATE _GLFW_WAYLAND) 55b877906bSopenharmony_ci target_sources(glfw PRIVATE wl_platform.h xkb_unicode.h wl_init.c 56b877906bSopenharmony_ci wl_monitor.c wl_window.c xkb_unicode.c) 57b877906bSopenharmony_ciendif() 58b877906bSopenharmony_ci 59b877906bSopenharmony_ciif (GLFW_BUILD_X11 OR GLFW_BUILD_WAYLAND) 60b877906bSopenharmony_ci if (CMAKE_SYSTEM_NAME STREQUAL "Linux") 61b877906bSopenharmony_ci target_sources(glfw PRIVATE linux_joystick.h linux_joystick.c) 62b877906bSopenharmony_ci endif() 63b877906bSopenharmony_ci target_sources(glfw PRIVATE posix_poll.h posix_poll.c) 64b877906bSopenharmony_ciendif() 65b877906bSopenharmony_ci 66b877906bSopenharmony_ciif (GLFW_BUILD_WAYLAND) 67b877906bSopenharmony_ci include(CheckIncludeFiles) 68b877906bSopenharmony_ci include(CheckFunctionExists) 69b877906bSopenharmony_ci check_function_exists(memfd_create HAVE_MEMFD_CREATE) 70b877906bSopenharmony_ci if (HAVE_MEMFD_CREATE) 71b877906bSopenharmony_ci target_compile_definitions(glfw PRIVATE HAVE_MEMFD_CREATE) 72b877906bSopenharmony_ci endif() 73b877906bSopenharmony_ci 74b877906bSopenharmony_ci find_program(WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner) 75b877906bSopenharmony_ci if (NOT WAYLAND_SCANNER_EXECUTABLE) 76b877906bSopenharmony_ci message(FATAL_ERROR "Failed to find wayland-scanner") 77b877906bSopenharmony_ci endif() 78b877906bSopenharmony_ci 79b877906bSopenharmony_ci macro(generate_wayland_protocol protocol_file) 80b877906bSopenharmony_ci set(protocol_path "${GLFW_SOURCE_DIR}/deps/wayland/${protocol_file}") 81b877906bSopenharmony_ci 82b877906bSopenharmony_ci string(REGEX REPLACE "\\.xml$" "-client-protocol.h" header_file ${protocol_file}) 83b877906bSopenharmony_ci string(REGEX REPLACE "\\.xml$" "-client-protocol-code.h" code_file ${protocol_file}) 84b877906bSopenharmony_ci 85b877906bSopenharmony_ci add_custom_command(OUTPUT ${header_file} 86b877906bSopenharmony_ci COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" client-header "${protocol_path}" ${header_file} 87b877906bSopenharmony_ci DEPENDS "${protocol_path}" 88b877906bSopenharmony_ci VERBATIM) 89b877906bSopenharmony_ci 90b877906bSopenharmony_ci add_custom_command(OUTPUT ${code_file} 91b877906bSopenharmony_ci COMMAND "${WAYLAND_SCANNER_EXECUTABLE}" private-code "${protocol_path}" ${code_file} 92b877906bSopenharmony_ci DEPENDS "${protocol_path}" 93b877906bSopenharmony_ci VERBATIM) 94b877906bSopenharmony_ci 95b877906bSopenharmony_ci target_sources(glfw PRIVATE ${header_file} ${code_file}) 96b877906bSopenharmony_ci endmacro() 97b877906bSopenharmony_ci 98b877906bSopenharmony_ci generate_wayland_protocol("wayland.xml") 99b877906bSopenharmony_ci generate_wayland_protocol("viewporter.xml") 100b877906bSopenharmony_ci generate_wayland_protocol("xdg-shell.xml") 101b877906bSopenharmony_ci generate_wayland_protocol("idle-inhibit-unstable-v1.xml") 102b877906bSopenharmony_ci generate_wayland_protocol("pointer-constraints-unstable-v1.xml") 103b877906bSopenharmony_ci generate_wayland_protocol("relative-pointer-unstable-v1.xml") 104b877906bSopenharmony_ci generate_wayland_protocol("fractional-scale-v1.xml") 105b877906bSopenharmony_ci generate_wayland_protocol("xdg-activation-v1.xml") 106b877906bSopenharmony_ci generate_wayland_protocol("xdg-decoration-unstable-v1.xml") 107b877906bSopenharmony_ciendif() 108b877906bSopenharmony_ci 109b877906bSopenharmony_ciif (WIN32 AND GLFW_BUILD_SHARED_LIBRARY) 110b877906bSopenharmony_ci configure_file(glfw.rc.in glfw.rc @ONLY) 111b877906bSopenharmony_ci target_sources(glfw PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/glfw.rc") 112b877906bSopenharmony_ciendif() 113b877906bSopenharmony_ci 114b877906bSopenharmony_ciif (UNIX AND GLFW_BUILD_SHARED_LIBRARY) 115b877906bSopenharmony_ci # On Unix-like systems, shared libraries can use the soname system. 116b877906bSopenharmony_ci set(GLFW_LIB_NAME glfw) 117b877906bSopenharmony_cielse() 118b877906bSopenharmony_ci set(GLFW_LIB_NAME glfw3) 119b877906bSopenharmony_ciendif() 120b877906bSopenharmony_ciset(GLFW_LIB_NAME_SUFFIX "") 121b877906bSopenharmony_ci 122b877906bSopenharmony_ciset_target_properties(glfw PROPERTIES 123b877906bSopenharmony_ci OUTPUT_NAME ${GLFW_LIB_NAME} 124b877906bSopenharmony_ci VERSION ${GLFW_VERSION_MAJOR}.${GLFW_VERSION_MINOR} 125b877906bSopenharmony_ci SOVERSION ${GLFW_VERSION_MAJOR} 126b877906bSopenharmony_ci POSITION_INDEPENDENT_CODE ON 127b877906bSopenharmony_ci C_STANDARD 99 128b877906bSopenharmony_ci C_EXTENSIONS OFF 129b877906bSopenharmony_ci DEFINE_SYMBOL _GLFW_BUILD_DLL 130b877906bSopenharmony_ci FOLDER "GLFW3") 131b877906bSopenharmony_ci 132b877906bSopenharmony_citarget_include_directories(glfw PUBLIC 133b877906bSopenharmony_ci "$<BUILD_INTERFACE:${GLFW_SOURCE_DIR}/include>" 134b877906bSopenharmony_ci "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>") 135b877906bSopenharmony_citarget_include_directories(glfw PRIVATE 136b877906bSopenharmony_ci "${GLFW_SOURCE_DIR}/src" 137b877906bSopenharmony_ci "${GLFW_BINARY_DIR}/src") 138b877906bSopenharmony_citarget_link_libraries(glfw PRIVATE Threads::Threads) 139b877906bSopenharmony_ci 140b877906bSopenharmony_ci# Workaround for CMake not knowing about .m files before version 3.16 141b877906bSopenharmony_ciif (CMAKE_VERSION VERSION_LESS "3.16" AND APPLE) 142b877906bSopenharmony_ci set_source_files_properties(cocoa_init.m cocoa_joystick.m cocoa_monitor.m 143b877906bSopenharmony_ci cocoa_window.m nsgl_context.m PROPERTIES 144b877906bSopenharmony_ci LANGUAGE C) 145b877906bSopenharmony_ciendif() 146b877906bSopenharmony_ci 147b877906bSopenharmony_ciif (GLFW_BUILD_WIN32) 148b877906bSopenharmony_ci list(APPEND glfw_PKG_LIBS "-lgdi32") 149b877906bSopenharmony_ciendif() 150b877906bSopenharmony_ci 151b877906bSopenharmony_ciif (GLFW_BUILD_COCOA) 152b877906bSopenharmony_ci target_link_libraries(glfw PRIVATE "-framework Cocoa" 153b877906bSopenharmony_ci "-framework IOKit" 154b877906bSopenharmony_ci "-framework CoreFoundation" 155b877906bSopenharmony_ci "-framework QuartzCore") 156b877906bSopenharmony_ci 157b877906bSopenharmony_ci set(glfw_PKG_DEPS "") 158b877906bSopenharmony_ci set(glfw_PKG_LIBS "-framework Cocoa -framework IOKit -framework CoreFoundation -framework QuartzCore") 159b877906bSopenharmony_ciendif() 160b877906bSopenharmony_ci 161b877906bSopenharmony_ciif (GLFW_BUILD_WAYLAND) 162b877906bSopenharmony_ci include(FindPkgConfig) 163b877906bSopenharmony_ci 164b877906bSopenharmony_ci pkg_check_modules(Wayland REQUIRED 165b877906bSopenharmony_ci wayland-client>=0.2.7 166b877906bSopenharmony_ci wayland-cursor>=0.2.7 167b877906bSopenharmony_ci wayland-egl>=0.2.7 168b877906bSopenharmony_ci xkbcommon>=0.5.0) 169b877906bSopenharmony_ci 170b877906bSopenharmony_ci target_include_directories(glfw PRIVATE ${Wayland_INCLUDE_DIRS}) 171b877906bSopenharmony_ci 172b877906bSopenharmony_ci if (NOT CMAKE_SYSTEM_NAME STREQUAL "Linux") 173b877906bSopenharmony_ci find_package(EpollShim) 174b877906bSopenharmony_ci if (EPOLLSHIM_FOUND) 175b877906bSopenharmony_ci target_include_directories(glfw PRIVATE ${EPOLLSHIM_INCLUDE_DIRS}) 176b877906bSopenharmony_ci target_link_libraries(glfw PRIVATE ${EPOLLSHIM_LIBRARIES}) 177b877906bSopenharmony_ci endif() 178b877906bSopenharmony_ci endif() 179b877906bSopenharmony_ciendif() 180b877906bSopenharmony_ci 181b877906bSopenharmony_ciif (GLFW_BUILD_X11) 182b877906bSopenharmony_ci find_package(X11 REQUIRED) 183b877906bSopenharmony_ci target_include_directories(glfw PRIVATE "${X11_X11_INCLUDE_PATH}") 184b877906bSopenharmony_ci 185b877906bSopenharmony_ci # Check for XRandR (modern resolution switching and gamma control) 186b877906bSopenharmony_ci if (NOT X11_Xrandr_INCLUDE_PATH) 187b877906bSopenharmony_ci message(FATAL_ERROR "RandR headers not found; install libxrandr development package") 188b877906bSopenharmony_ci endif() 189b877906bSopenharmony_ci target_include_directories(glfw PRIVATE "${X11_Xrandr_INCLUDE_PATH}") 190b877906bSopenharmony_ci 191b877906bSopenharmony_ci # Check for Xinerama (legacy multi-monitor support) 192b877906bSopenharmony_ci if (NOT X11_Xinerama_INCLUDE_PATH) 193b877906bSopenharmony_ci message(FATAL_ERROR "Xinerama headers not found; install libxinerama development package") 194b877906bSopenharmony_ci endif() 195b877906bSopenharmony_ci target_include_directories(glfw PRIVATE "${X11_Xinerama_INCLUDE_PATH}") 196b877906bSopenharmony_ci 197b877906bSopenharmony_ci # Check for Xkb (X keyboard extension) 198b877906bSopenharmony_ci if (NOT X11_Xkb_INCLUDE_PATH) 199b877906bSopenharmony_ci message(FATAL_ERROR "XKB headers not found; install X11 development package") 200b877906bSopenharmony_ci endif() 201b877906bSopenharmony_ci target_include_directories(glfw PRIVATE "${X11_Xkb_INCLUDE_PATH}") 202b877906bSopenharmony_ci 203b877906bSopenharmony_ci # Check for Xcursor (cursor creation from RGBA images) 204b877906bSopenharmony_ci if (NOT X11_Xcursor_INCLUDE_PATH) 205b877906bSopenharmony_ci message(FATAL_ERROR "Xcursor headers not found; install libxcursor development package") 206b877906bSopenharmony_ci endif() 207b877906bSopenharmony_ci target_include_directories(glfw PRIVATE "${X11_Xcursor_INCLUDE_PATH}") 208b877906bSopenharmony_ci 209b877906bSopenharmony_ci # Check for XInput (modern HID input) 210b877906bSopenharmony_ci if (NOT X11_Xi_INCLUDE_PATH) 211b877906bSopenharmony_ci message(FATAL_ERROR "XInput headers not found; install libxi development package") 212b877906bSopenharmony_ci endif() 213b877906bSopenharmony_ci target_include_directories(glfw PRIVATE "${X11_Xi_INCLUDE_PATH}") 214b877906bSopenharmony_ci 215b877906bSopenharmony_ci # Check for X Shape (custom window input shape) 216b877906bSopenharmony_ci if (NOT X11_Xshape_INCLUDE_PATH) 217b877906bSopenharmony_ci message(FATAL_ERROR "X Shape headers not found; install libxext development package") 218b877906bSopenharmony_ci endif() 219b877906bSopenharmony_ci target_include_directories(glfw PRIVATE "${X11_Xshape_INCLUDE_PATH}") 220b877906bSopenharmony_ciendif() 221b877906bSopenharmony_ci 222b877906bSopenharmony_ciif (UNIX AND NOT APPLE) 223b877906bSopenharmony_ci find_library(RT_LIBRARY rt) 224b877906bSopenharmony_ci mark_as_advanced(RT_LIBRARY) 225b877906bSopenharmony_ci if (RT_LIBRARY) 226b877906bSopenharmony_ci target_link_libraries(glfw PRIVATE "${RT_LIBRARY}") 227b877906bSopenharmony_ci list(APPEND glfw_PKG_LIBS "-lrt") 228b877906bSopenharmony_ci endif() 229b877906bSopenharmony_ci 230b877906bSopenharmony_ci find_library(MATH_LIBRARY m) 231b877906bSopenharmony_ci mark_as_advanced(MATH_LIBRARY) 232b877906bSopenharmony_ci if (MATH_LIBRARY) 233b877906bSopenharmony_ci target_link_libraries(glfw PRIVATE "${MATH_LIBRARY}") 234b877906bSopenharmony_ci list(APPEND glfw_PKG_LIBS "-lm") 235b877906bSopenharmony_ci endif() 236b877906bSopenharmony_ci 237b877906bSopenharmony_ci if (CMAKE_DL_LIBS) 238b877906bSopenharmony_ci target_link_libraries(glfw PRIVATE "${CMAKE_DL_LIBS}") 239b877906bSopenharmony_ci list(APPEND glfw_PKG_LIBS "-l${CMAKE_DL_LIBS}") 240b877906bSopenharmony_ci endif() 241b877906bSopenharmony_ciendif() 242b877906bSopenharmony_ci 243b877906bSopenharmony_ciif (WIN32) 244b877906bSopenharmony_ci if (GLFW_USE_HYBRID_HPG) 245b877906bSopenharmony_ci target_compile_definitions(glfw PRIVATE _GLFW_USE_HYBRID_HPG) 246b877906bSopenharmony_ci endif() 247b877906bSopenharmony_ciendif() 248b877906bSopenharmony_ci 249b877906bSopenharmony_ci# Enable a reasonable set of warnings 250b877906bSopenharmony_ci# NOTE: The order matters here, Clang-CL matches both MSVC and Clang 251b877906bSopenharmony_ciif (MSVC) 252b877906bSopenharmony_ci target_compile_options(glfw PRIVATE "/W3") 253b877906bSopenharmony_cielseif (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR 254b877906bSopenharmony_ci CMAKE_C_COMPILER_ID STREQUAL "Clang" OR 255b877906bSopenharmony_ci CMAKE_C_COMPILER_ID STREQUAL "AppleClang") 256b877906bSopenharmony_ci 257b877906bSopenharmony_ci target_compile_options(glfw PRIVATE "-Wall") 258b877906bSopenharmony_ciendif() 259b877906bSopenharmony_ci 260b877906bSopenharmony_ciif (GLFW_BUILD_WIN32) 261b877906bSopenharmony_ci target_compile_definitions(glfw PRIVATE UNICODE _UNICODE) 262b877906bSopenharmony_ciendif() 263b877906bSopenharmony_ci 264b877906bSopenharmony_ci# HACK: When building on MinGW, WINVER and UNICODE need to be defined before 265b877906bSopenharmony_ci# the inclusion of stddef.h (by glfw3.h), which is itself included before 266b877906bSopenharmony_ci# win32_platform.h. We define them here until a saner solution can be found 267b877906bSopenharmony_ci# NOTE: MinGW-w64 and Visual C++ do /not/ need this hack. 268b877906bSopenharmony_ciif (MINGW) 269b877906bSopenharmony_ci target_compile_definitions(glfw PRIVATE WINVER=0x0501) 270b877906bSopenharmony_ciendif() 271b877906bSopenharmony_ci 272b877906bSopenharmony_ci# Workaround for legacy MinGW not providing XInput and DirectInput 273b877906bSopenharmony_ciif (MINGW) 274b877906bSopenharmony_ci include(CheckIncludeFile) 275b877906bSopenharmony_ci check_include_file(dinput.h DINPUT_H_FOUND) 276b877906bSopenharmony_ci check_include_file(xinput.h XINPUT_H_FOUND) 277b877906bSopenharmony_ci if (NOT DINPUT_H_FOUND OR NOT XINPUT_H_FOUND) 278b877906bSopenharmony_ci target_include_directories(glfw PRIVATE "${GLFW_SOURCE_DIR}/deps/mingw") 279b877906bSopenharmony_ci endif() 280b877906bSopenharmony_ciendif() 281b877906bSopenharmony_ci 282b877906bSopenharmony_ci# Workaround for the MS CRT deprecating parts of the standard library 283b877906bSopenharmony_ciif (MSVC OR CMAKE_C_SIMULATE_ID STREQUAL "MSVC") 284b877906bSopenharmony_ci target_compile_definitions(glfw PRIVATE _CRT_SECURE_NO_WARNINGS) 285b877906bSopenharmony_ciendif() 286b877906bSopenharmony_ci 287b877906bSopenharmony_ci# Workaround for -std=c99 on Linux disabling _DEFAULT_SOURCE (POSIX 2008 and more) 288b877906bSopenharmony_ciif (CMAKE_SYSTEM_NAME STREQUAL "Linux") 289b877906bSopenharmony_ci target_compile_definitions(glfw PRIVATE _DEFAULT_SOURCE) 290b877906bSopenharmony_ciendif() 291b877906bSopenharmony_ci 292b877906bSopenharmony_ciif (GLFW_BUILD_SHARED_LIBRARY) 293b877906bSopenharmony_ci if (WIN32) 294b877906bSopenharmony_ci if (MINGW) 295b877906bSopenharmony_ci # Remove the dependency on the shared version of libgcc 296b877906bSopenharmony_ci # NOTE: MinGW-w64 has the correct default but MinGW needs this 297b877906bSopenharmony_ci target_link_libraries(glfw PRIVATE "-static-libgcc") 298b877906bSopenharmony_ci 299b877906bSopenharmony_ci # Remove the lib prefix on the DLL (but not the import library) 300b877906bSopenharmony_ci set_target_properties(glfw PROPERTIES PREFIX "") 301b877906bSopenharmony_ci 302b877906bSopenharmony_ci # Add a suffix to the import library to avoid naming conflicts 303b877906bSopenharmony_ci set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.a") 304b877906bSopenharmony_ci else() 305b877906bSopenharmony_ci # Add a suffix to the import library to avoid naming conflicts 306b877906bSopenharmony_ci set_target_properties(glfw PROPERTIES IMPORT_SUFFIX "dll.lib") 307b877906bSopenharmony_ci endif() 308b877906bSopenharmony_ci set (GLFW_LIB_NAME_SUFFIX "dll") 309b877906bSopenharmony_ci 310b877906bSopenharmony_ci target_compile_definitions(glfw INTERFACE GLFW_DLL) 311b877906bSopenharmony_ci endif() 312b877906bSopenharmony_ci 313b877906bSopenharmony_ci if (MINGW) 314b877906bSopenharmony_ci # Enable link-time exploit mitigation features enabled by default on MSVC 315b877906bSopenharmony_ci include(CheckCCompilerFlag) 316b877906bSopenharmony_ci 317b877906bSopenharmony_ci # Compatibility with data execution prevention (DEP) 318b877906bSopenharmony_ci set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat") 319b877906bSopenharmony_ci check_c_compiler_flag("" _GLFW_HAS_DEP) 320b877906bSopenharmony_ci if (_GLFW_HAS_DEP) 321b877906bSopenharmony_ci target_link_libraries(glfw PRIVATE "-Wl,--nxcompat") 322b877906bSopenharmony_ci endif() 323b877906bSopenharmony_ci 324b877906bSopenharmony_ci # Compatibility with address space layout randomization (ASLR) 325b877906bSopenharmony_ci set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase") 326b877906bSopenharmony_ci check_c_compiler_flag("" _GLFW_HAS_ASLR) 327b877906bSopenharmony_ci if (_GLFW_HAS_ASLR) 328b877906bSopenharmony_ci target_link_libraries(glfw PRIVATE "-Wl,--dynamicbase") 329b877906bSopenharmony_ci endif() 330b877906bSopenharmony_ci 331b877906bSopenharmony_ci # Compatibility with 64-bit address space layout randomization (ASLR) 332b877906bSopenharmony_ci set(CMAKE_REQUIRED_FLAGS "-Wl,--high-entropy-va") 333b877906bSopenharmony_ci check_c_compiler_flag("" _GLFW_HAS_64ASLR) 334b877906bSopenharmony_ci if (_GLFW_HAS_64ASLR) 335b877906bSopenharmony_ci target_link_libraries(glfw PRIVATE "-Wl,--high-entropy-va") 336b877906bSopenharmony_ci endif() 337b877906bSopenharmony_ci 338b877906bSopenharmony_ci # Clear flags again to avoid breaking later tests 339b877906bSopenharmony_ci set(CMAKE_REQUIRED_FLAGS) 340b877906bSopenharmony_ci endif() 341b877906bSopenharmony_ci 342b877906bSopenharmony_ci if (UNIX) 343b877906bSopenharmony_ci # Hide symbols not explicitly tagged for export from the shared library 344b877906bSopenharmony_ci target_compile_options(glfw PRIVATE "-fvisibility=hidden") 345b877906bSopenharmony_ci endif() 346b877906bSopenharmony_ciendif() 347b877906bSopenharmony_ci 348b877906bSopenharmony_ciforeach(arg ${glfw_PKG_DEPS}) 349b877906bSopenharmony_ci string(APPEND deps " ${arg}") 350b877906bSopenharmony_ciendforeach() 351b877906bSopenharmony_ciforeach(arg ${glfw_PKG_LIBS}) 352b877906bSopenharmony_ci string(APPEND libs " ${arg}") 353b877906bSopenharmony_ciendforeach() 354b877906bSopenharmony_ci 355b877906bSopenharmony_ciset(GLFW_PKG_CONFIG_REQUIRES_PRIVATE "${deps}" CACHE INTERNAL 356b877906bSopenharmony_ci "GLFW pkg-config Requires.private") 357b877906bSopenharmony_ciset(GLFW_PKG_CONFIG_LIBS_PRIVATE "${libs}" CACHE INTERNAL 358b877906bSopenharmony_ci "GLFW pkg-config Libs.private") 359b877906bSopenharmony_ci 360b877906bSopenharmony_ciconfigure_file("${GLFW_SOURCE_DIR}/CMake/glfw3.pc.in" glfw3.pc @ONLY) 361b877906bSopenharmony_ci 362b877906bSopenharmony_ciif (GLFW_INSTALL) 363b877906bSopenharmony_ci install(TARGETS glfw 364b877906bSopenharmony_ci EXPORT glfwTargets 365b877906bSopenharmony_ci RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" 366b877906bSopenharmony_ci ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" 367b877906bSopenharmony_ci LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}") 368b877906bSopenharmony_ciendif() 369b877906bSopenharmony_ci 370