summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRafael G. Martins <rafael@rafaelmartins.eng.br>2024-05-21 03:12:18 +0200
committerRafael G. Martins <rafael@rafaelmartins.eng.br>2024-05-21 03:12:18 +0200
commit2f4c1de6c3fa23e073b81b9dd9fd9869037612db (patch)
treecc4d193728596bdd17367782fb8bccc686f2de5f /tests
parentb54b8f5b25403cf3b9623804b2491ec78a8b913e (diff)
downloadblogc-2f4c1de6c3fa23e073b81b9dd9fd9869037612db.tar.gz
blogc-2f4c1de6c3fa23e073b81b9dd9fd9869037612db.tar.bz2
blogc-2f4c1de6c3fa23e073b81b9dd9fd9869037612db.zip
build: tests: support cmake < 3.25
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt22
1 files changed, 15 insertions, 7 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index e1ca881..8a1d7b0 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -8,13 +8,21 @@ find_program(BASH bash HINTS /bin /usr/bin REQUIRED)
find_program(DIFF diff REQUIRED)
find_program(TEE tee REQUIRED)
-try_compile(HAVE_LD_WRAP
- SOURCE_FROM_CONTENT
- main.c
- "#include <stdlib.h>\nvoid __real_exit(int status);\nvoid __wrap_exit(int s){__real_exit(0);}\nint main(){exit(1);}"
- LINK_OPTIONS
- "-Wl,--wrap=exit"
-)
+if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.25")
+ try_compile(HAVE_LD_WRAP
+ SOURCES
+ "${CMAKE_SOURCE_DIR}/cmake/try_compile/ldwrap.c"
+ LINK_OPTIONS
+ "-Wl,--wrap=exit"
+ )
+else()
+ try_compile(HAVE_LD_WRAP "${CMAKE_BINARY_DIR}/ldwrap"
+ SOURCES
+ "${CMAKE_SOURCE_DIR}/cmake/try_compile/ldwrap.c"
+ LINK_OPTIONS
+ "-Wl,--wrap=exit"
+ )
+endif()
function(blogc_executable_test _libname _src)
if (NOT CMOCKA_FOUND)