Skip to content
Snippets Groups Projects
Commit e8d5f19e authored by Georg Sauthoff's avatar Georg Sauthoff
Browse files

Modernize cmake build file

parent d42ad293
No related branches found
No related tags found
No related merge requests found
...@@ -16,16 +16,16 @@ add_subdirectory(libixxx) ...@@ -16,16 +16,16 @@ add_subdirectory(libixxx)
add_subdirectory(libixxxutil) add_subdirectory(libixxxutil)
if((CMAKE_C_COMPILER_ID STREQUAL "GNU" if((CMAKE_C_COMPILER_ID STREQUAL "GNU"
AND CMAKE_C_COMPILER_VERSION VERSION_LESS "5") AND CMAKE_C_COMPILER_VERSION VERSION_LESS "5")
OR OR
(CMAKE_C_COMPILER_ID STREQUAL "Clang" (CMAKE_C_COMPILER_ID STREQUAL "Clang"
AND CMAKE_C_COMPILER_VERSION VERSION_LESS "4") AND CMAKE_C_COMPILER_VERSION VERSION_LESS "4")
) )
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(NO_SANITIZE "-fno-sanitize=address") set(NO_SANITIZE "-fno-sanitize=address")
endif() endif()
else() else()
set(NO_SANITIZE "-fno-sanitize=all") set(NO_SANITIZE "-fno-sanitize=all")
endif() endif()
check_library_exists(c clock_gettime "" CLOCK_GETTIME_IN_C) check_library_exists(c clock_gettime "" CLOCK_GETTIME_IN_C)
...@@ -36,101 +36,78 @@ else() ...@@ -36,101 +36,78 @@ else()
endif() endif()
add_executable(silence silence.c) add_executable(silence silence.c)
set_property(TARGET silence PROPERTY COMPILE_DEFINITIONS _GNU_SOURCE) target_compile_definitions(silence PRIVATE _GNU_SOURCE)
add_executable(fail test/fail.c) add_executable(fail test/fail.c)
add_executable(silencce silence.cc) add_executable(silencce silence.cc)
# not necessary, e.g. on Fedora 26
#set_property(TARGET silencce PROPERTY COMPILE_DEFINITIONS _GNU_SOURCE)
set_property(TARGET silencce PROPERTY INCLUDE_DIRECTORIES
${CMAKE_SOURCE_DIR}/libixxx
${CMAKE_SOURCE_DIR}/libixxxutil
)
target_link_libraries(silencce target_link_libraries(silencce
ixxxutil_static ixxxutil_static
ixxx_static ixxx_static
) )
add_executable(oldprocs oldprocs.cc) add_executable(oldprocs oldprocs.cc)
set_property(TARGET oldprocs PROPERTY INCLUDE_DIRECTORIES
${CMAKE_SOURCE_DIR}/libixxx
${CMAKE_SOURCE_DIR}/libixxxutil
)
target_link_libraries(oldprocs target_link_libraries(oldprocs
ixxxutil_static ixxxutil_static
ixxx_static ixxx_static
) )
add_executable(lockf lockf.c) add_executable(lockf lockf.c)
add_executable(dcat dcat.cc) add_executable(dcat dcat.cc)
set_property(TARGET dcat PROPERTY INCLUDE_DIRECTORIES
${CMAKE_SOURCE_DIR}/libixxx
${CMAKE_SOURCE_DIR}/libixxxutil
)
target_link_libraries(dcat target_link_libraries(dcat
ixxxutil_static ixxxutil_static
ixxx_static ixxx_static
) )
add_executable(swap swap.c) add_executable(swap swap.c)
set_property(TARGET swap PROPERTY INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}) target_include_directories(swap PRIVATE ${CMAKE_BINARY_DIR})
add_executable(pargs pargs.c) add_executable(pargs pargs.c)
set_property(TARGET pargs PROPERTY COMPILE_DEFINITIONS _GNU_SOURCE) target_compile_definitions(pargs PRIVATE _GNU_SOURCE)
add_executable(pargs32 pargs.c) add_executable (pargs32 pargs.c)
set_property(TARGET pargs32 PROPERTY COMPILE_DEFINITIONS _GNU_SOURCE) target_compile_definitions(pargs32 PRIVATE _GNU_SOURCE)
set_target_properties(pargs32 target_compile_options (pargs32 PRIVATE -m32 ${NO_SANITIZE})
PROPERTIES COMPILE_FLAGS "-m32 ${NO_SANITIZE}" target_link_options (pargs32 PRIVATE -m32 ${NO_SANITIZE})
LINK_FLAGS "-m32 ${NO_SANITIZE}")
# NOTE: when compiling with sanitizers (address etc.) it's important # NOTE: when compiling with sanitizers (address etc.) it's important
# that these test programs are compiled without those flags because # that these test programs are compiled without those flags because
# we need to create some core files of them. # we need to create some core files of them.
# Apparently, the sanitizing might blow up the core files, i.e. yielding: # Apparently, the sanitizing might blow up the core files, i.e. yielding:
# warning: Failed to write corefile contents (No space left on device). # warning: Failed to write corefile contents (No space left on device).
add_executable(snooze test/snooze.c) add_executable (snooze test/snooze.c)
set_target_properties(snooze target_compile_options(snooze PRIVATE ${NO_SANITIZE})
PROPERTIES COMPILE_FLAGS "${NO_SANITIZE}" LINK_FLAGS "${NO_SANITIZE}") target_link_options (snooze PRIVATE ${NO_SANITIZE})
add_executable(snooze32 test/snooze.c) add_executable (snooze32 test/snooze.c)
set_target_properties(snooze32 target_compile_options(snooze32 PRIVATE -m32 ${NO_SANITIZE})
PROPERTIES COMPILE_FLAGS "-m32 ${NO_SANITIZE}" target_link_options (snooze32 PRIVATE -m32 ${NO_SANITIZE})
LINK_FLAGS "-m32 ${NO_SANITIZE}") add_executable (busy_snooze test/busy_snooze.c)
add_executable(busy_snooze test/busy_snooze.c) target_compile_options(busy_snooze PRIVATE ${NO_SANITIZE})
set_target_properties(busy_snooze target_link_options (busy_snooze PRIVATE ${NO_SANITIZE})
PROPERTIES COMPILE_FLAGS "${NO_SANITIZE}" LINK_FLAGS "${NO_SANITIZE}") target_link_libraries (busy_snooze ${RT_LIB})
target_link_libraries(busy_snooze ${RT_LIB})
add_executable(searchb searchb.c) add_executable(searchb searchb.c)
add_executable(searchbxx searchb.cc) add_executable(searchbxx searchb.cc)
set_property(TARGET searchbxx PROPERTY INCLUDE_DIRECTORIES
${CMAKE_SOURCE_DIR}/libixxx
${CMAKE_SOURCE_DIR}/libixxxutil
)
target_link_libraries(searchbxx target_link_libraries(searchbxx
ixxxutil_static ixxxutil_static
ixxx_static ixxx_static
) )
add_executable(exec exec.c) add_executable(exec exec.c)
add_executable(adjtimex adjtimex.c) add_executable(adjtimex adjtimex.c)
add_executable(pq pq.cc syscalls.cc) add_executable(pq pq.cc syscalls.cc)
set_property(TARGET pq PROPERTY INCLUDE_DIRECTORIES target_link_libraries(pq PUBLIC
${CMAKE_SOURCE_DIR}/libixxx
${CMAKE_SOURCE_DIR}/libixxxutil
)
target_link_libraries(pq
ixxxutil_static ixxxutil_static
ixxx_static ixxx_static
) )
add_custom_target(check-old add_custom_target(check-old
COMMAND env src_dir=${CMAKE_CURRENT_SOURCE_DIR} COMMAND env src_dir=${CMAKE_CURRENT_SOURCE_DIR}
......
Subproject commit 16ad3b9cc39f8859289c813748d3b621bcfe0ec6 Subproject commit c309c5ff18e8a80c68bb79d9d9b7dbc0236ca339
Subproject commit 4d35a02edca617d092500be0dae2f740ffc93c73 Subproject commit 894bb1811bb572e053c43f3d240bdd2c310a1fb8
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment