From dc971798e898c06f3e9de0a93f00442e70371f3c Mon Sep 17 00:00:00 2001 From: t1c Date: Fri, 25 Apr 2025 16:31:14 +0800 Subject: [PATCH 1/6] Update CMakeLists.txt According to the CMake official documentation (as of version 3.28), the valid options for the configure_file command are limited to: @ONLY, ESCAPE_QUOTES, COPYONLY, and NEWLINE_STYLE, while IMMEDIATE is not recognized as a standard option. https://cmake.org/cmake/help/v3.28/command/configure_file.html#configure-file --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 398b36eb1..85de0fed9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -129,7 +129,7 @@ if (GLFW_INSTALL) # Only generate this target if no higher-level project already has if (NOT TARGET uninstall) configure_file(CMake/cmake_uninstall.cmake.in - cmake_uninstall.cmake IMMEDIATE @ONLY) + cmake_uninstall.cmake @ONLY) add_custom_target(uninstall "${CMAKE_COMMAND}" -P From 5d38860335862741544990df638ae38b3593318b Mon Sep 17 00:00:00 2001 From: t1c Date: Sun, 27 Apr 2025 20:27:46 +0800 Subject: [PATCH 2/6] Update CMakeLists.txt https://cmake.org/cmake/help/v3.28/variable/CMAKE_DL_LIBS.html#cmake-dl-libs https://cmake.org/cmake/help/v3.28/command/find_library.html#find-library --- src/CMakeLists.txt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1a085b2b6..aacdb296b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -216,21 +216,23 @@ endif() if (UNIX AND NOT APPLE) find_library(RT_LIBRARY rt) mark_as_advanced(RT_LIBRARY) - if (RT_LIBRARY) + if (NOT RT_LIBRARY STREQUAL "RT_LIBRARY-NOTFOUND") target_link_libraries(glfw PRIVATE "${RT_LIBRARY}") list(APPEND glfw_PKG_LIBS "-lrt") endif() find_library(MATH_LIBRARY m) mark_as_advanced(MATH_LIBRARY) - if (MATH_LIBRARY) + if (NOT MATH_LIBRARY STREQUAL "MATH_LIBRARY-NOTFOUND") target_link_libraries(glfw PRIVATE "${MATH_LIBRARY}") list(APPEND glfw_PKG_LIBS "-lm") endif() - if (CMAKE_DL_LIBS) - target_link_libraries(glfw PRIVATE "${CMAKE_DL_LIBS}") - list(APPEND glfw_PKG_LIBS "-l${CMAKE_DL_LIBS}") + find_library(DL_LIBRARY dl) + mark_as_advanced(DL_LIBRARY) + if (NOT DL_LIBRARY STREQUAL "DL_LIBRARY-NOTFOUND") + target_link_libraries(glfw PRIVATE "${DL_LIBRARY}") + list(APPEND glfw_PKG_LIBS "-ldl") endif() endif() From e14434c059471310a6c8f640615e17e2e62f25fa Mon Sep 17 00:00:00 2001 From: t1c Date: Mon, 28 Apr 2025 13:36:29 +0800 Subject: [PATCH 3/6] Update CMakeLists.txt https://cmake.org/cmake/help/v3.28/command/find_library.html#find-library --- examples/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index e7a037976..aca787d52 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -3,7 +3,7 @@ link_libraries(glfw) include_directories("${GLFW_SOURCE_DIR}/deps") -if (MATH_LIBRARY) +if (NOT MATH_LIBRARY STREQUAL "MATH_LIBRARY-NOTFOUND") link_libraries("${MATH_LIBRARY}") endif() @@ -38,7 +38,7 @@ add_executable(wave WIN32 MACOSX_BUNDLE wave.c ${ICON} ${GLAD_GL}) add_executable(windows WIN32 MACOSX_BUNDLE windows.c ${ICON} ${GLAD_GL}) target_link_libraries(particles Threads::Threads) -if (RT_LIBRARY) +if (NOT RT_LIBRARY STREQUAL "RT_LIBRARY-NOTFOUND") target_link_libraries(particles "${RT_LIBRARY}") endif() From dc77205ff284f5636b65fc5e44f650f6fd4e8380 Mon Sep 17 00:00:00 2001 From: t1c Date: Mon, 28 Apr 2025 13:44:34 +0800 Subject: [PATCH 4/6] Update CMakeLists.txt https://cmake.org/cmake/help/v3.28/command/find_library.html#find-library --- tests/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f81cfeb94..99d02874a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -3,7 +3,7 @@ link_libraries(glfw) include_directories("${GLFW_SOURCE_DIR}/deps") -if (MATH_LIBRARY) +if (NOT MATH_LIBRARY STREQUAL "MATH_LIBRARY-NOTFOUND") link_libraries("${MATH_LIBRARY}") endif() @@ -43,7 +43,7 @@ add_executable(window WIN32 MACOSX_BUNDLE window.c ${GLAD_GL}) target_link_libraries(empty Threads::Threads) target_link_libraries(threads Threads::Threads) -if (RT_LIBRARY) +if (NOT RT_LIBRARY STREQUAL "RT_LIBRARY-NOTFOUND") target_link_libraries(empty "${RT_LIBRARY}") target_link_libraries(threads "${RT_LIBRARY}") endif() From fc89a317fcb538f800dfbd9a01b05a81c9e918d7 Mon Sep 17 00:00:00 2001 From: t1c Date: Wed, 30 Apr 2025 13:06:11 +0800 Subject: [PATCH 5/6] Update CMakeLists.txt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit check_c_compiler_flag is used to check ​​compiler flags​​ (such as -Wall), not linker flags. Passing an empty string directly will result in checking nothing substantial, and the outcome may always be TRUE. --- src/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index aacdb296b..d058c1565 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -314,7 +314,7 @@ if (GLFW_BUILD_SHARED_LIBRARY) # Compatibility with data execution prevention (DEP) cmake_push_check_state() set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat") - check_c_compiler_flag("" _GLFW_HAS_DEP) + check_linker_flag(C "-Wl,--nxcompat" _GLFW_HAS_DEP) if (_GLFW_HAS_DEP) target_link_libraries(glfw PRIVATE "-Wl,--nxcompat") endif() @@ -323,7 +323,7 @@ if (GLFW_BUILD_SHARED_LIBRARY) # Compatibility with address space layout randomization (ASLR) cmake_push_check_state() set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase") - check_c_compiler_flag("" _GLFW_HAS_ASLR) + check_linker_flag(C "-Wl,--dynamicbase" _GLFW_HAS_ASLR) if (_GLFW_HAS_ASLR) target_link_libraries(glfw PRIVATE "-Wl,--dynamicbase") endif() @@ -332,7 +332,7 @@ if (GLFW_BUILD_SHARED_LIBRARY) # Compatibility with 64-bit address space layout randomization (ASLR) cmake_push_check_state() set(CMAKE_REQUIRED_FLAGS "-Wl,--high-entropy-va") - check_c_compiler_flag("" _GLFW_HAS_64ASLR) + check_linker_flag(C "-Wl,--high-entropy-va" _GLFW_HAS_64ASLR) if (_GLFW_HAS_64ASLR) target_link_libraries(glfw PRIVATE "-Wl,--high-entropy-va") endif() From 4d7ddae70cc82d7f47a1106520eca69740378b49 Mon Sep 17 00:00:00 2001 From: t1c Date: Wed, 30 Apr 2025 13:22:06 +0800 Subject: [PATCH 6/6] Update CMakeLists.txt check_c_source_compiles --- src/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d058c1565..272ecf93a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -314,7 +314,7 @@ if (GLFW_BUILD_SHARED_LIBRARY) # Compatibility with data execution prevention (DEP) cmake_push_check_state() set(CMAKE_REQUIRED_FLAGS "-Wl,--nxcompat") - check_linker_flag(C "-Wl,--nxcompat" _GLFW_HAS_DEP) + check_c_source_compiles("int main() { return 0; }" _GLFW_HAS_DEP) if (_GLFW_HAS_DEP) target_link_libraries(glfw PRIVATE "-Wl,--nxcompat") endif() @@ -323,7 +323,7 @@ if (GLFW_BUILD_SHARED_LIBRARY) # Compatibility with address space layout randomization (ASLR) cmake_push_check_state() set(CMAKE_REQUIRED_FLAGS "-Wl,--dynamicbase") - check_linker_flag(C "-Wl,--dynamicbase" _GLFW_HAS_ASLR) + check_c_source_compiles("int main() { return 0; }" _GLFW_HAS_ASLR) if (_GLFW_HAS_ASLR) target_link_libraries(glfw PRIVATE "-Wl,--dynamicbase") endif() @@ -332,7 +332,7 @@ if (GLFW_BUILD_SHARED_LIBRARY) # Compatibility with 64-bit address space layout randomization (ASLR) cmake_push_check_state() set(CMAKE_REQUIRED_FLAGS "-Wl,--high-entropy-va") - check_linker_flag(C "-Wl,--high-entropy-va" _GLFW_HAS_64ASLR) + check_c_source_compiles("int main() { return 0; }" _GLFW_HAS_64ASLR) if (_GLFW_HAS_64ASLR) target_link_libraries(glfw PRIVATE "-Wl,--high-entropy-va") endif()