summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt79
1 files changed, 58 insertions, 21 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1f888d1e..5a259431 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,5 @@
-cmake_minimum_required(VERSION 2.8.12.2)
+cmake_minimum_required(VERSION 2.8.12.2...3.30.0)
+cmake_policy(VERSION ${CMAKE_VERSION})
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
@@ -7,23 +8,29 @@ project(ouroboros C)
include(GNUInstallDirs)
set(PACKAGE_VERSION_MAJOR 0)
-set(PACKAGE_VERSION_MINOR 11)
-set(PACKAGE_VERSION_PATCH 2)
+set(PACKAGE_VERSION_MINOR 21)
+set(PACKAGE_VERSION_PATCH 4)
set(PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
set(PACKAGE_DESCRIPTION "The Ouroboros prototype")
-set(PACKAGE_URL "http://ouroboros.ilabt.imec.be")
-set(PACKAGE_BUGREPORT "http://ouroboros.ilabt.imec.be/bugzilla/")
+set(PACKAGE_URL "http://ouroboros.rocks")
+set(PACKAGE_BUGREPORT "http://ouroboros.rocks/bugzilla/")
set(PACKAGE_VERSION
"${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}")
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
- "Build type (Release, Debug, DebugASan, DebugTSan, DebugLSan)" FORCE)
+ "Build type (Release, Debug, DebugASan, DebugTSan, DebugLSan, DebugUSan, DebugAnalyzer)" FORCE)
endif()
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
- set(CMAKE_INSTALL_PREFIX "/usr" CACHE STRING "Installation Prefix" FORCE)
+ if (APPLE)
+ set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE STRING
+ "Installation Prefix" FORCE)
+ else()
+ set(CMAKE_INSTALL_PREFIX "/usr" CACHE STRING
+ "Installation Prefix" FORCE)
+ endif()
endif ()
if (APPLE)
@@ -59,11 +66,12 @@ include(CompilerUtils)
test_and_set_c_compiler_flag_global(-std=c89)
test_and_set_c_compiler_flag_global(-Wall)
# -Wextra may fail on clobbered warning due to pthread_cleanup
-# test_and_set_c_compiler_flag_global(-Wextra)
+test_and_set_c_compiler_flag_global(-Wno-clobbered)
+test_and_set_c_compiler_flag_global(-Wextra)
# explicitly add other flags in -Wextra
test_and_set_c_compiler_flag_global(-Wempty-body)
test_and_set_c_compiler_flag_global(-Wignored-qualifiers)
-test_and_set_c_compiler_flag_global(-Wimplicit-fallthrough)
+test_and_set_c_compiler_flag_global(-Wimplicit-fallthrough=4)
test_and_set_c_compiler_flag_global(-Wmissing-field-initializers)
test_and_set_c_compiler_flag_global(-Wmissing-parameter-type)
test_and_set_c_compiler_flag_global(-Wold-style-declaration)
@@ -74,27 +82,39 @@ test_and_set_c_compiler_flag_global(-Wuninitialized)
test_and_set_c_compiler_flag_global(-Wshift-negative-value)
test_and_set_c_compiler_flag_global(-Wunused-parameter)
test_and_set_c_compiler_flag_global(-Wunused-but-set-parameter)
-# -Wextra parameters
test_and_set_c_compiler_flag_global(-Werror)
test_and_set_c_compiler_flag_global(-Wundef)
test_and_set_c_compiler_flag_global(-Wpointer-arith)
test_and_set_c_compiler_flag_global(-Wstrict-prototypes)
-#Wswitch-default check fails on the swig-generated code
-#test_and_set_c_compiler_flag_global(-Wswitch-default)
+test_and_set_c_compiler_flag_global(-Wvla)
+test_and_set_c_compiler_flag_global(-Wswitch-default)
+test_and_set_c_compiler_flag_global(-Wreturn-type)
test_and_set_c_compiler_flag_global(-Wunreachable-code)
test_and_set_c_compiler_flag_global(-Wdeclaration-after-statement)
+test_and_set_c_compiler_flag_global(-Winfinite-recursion)
test_and_set_c_compiler_flag_global(-fmax-errors=5)
+
if (CMAKE_BUILD_TYPE STREQUAL "Release")
test_and_set_c_compiler_flag_global(-O3)
-else ()
+elseif (CMAKE_BUILD_TYPE STREQUAL "Debug")
+ test_and_set_c_compiler_flag_global(-g)
+elseif (CMAKE_BUILD_TYPE STREQUAL "DebugASan")
test_and_set_c_compiler_flag_global(-g)
-endif ()
-if (CMAKE_BUILD_TYPE STREQUAL "DebugASan")
test_and_set_c_compiler_flag_global(-fsanitize=address)
elseif (CMAKE_BUILD_TYPE STREQUAL "DebugTSan")
+ test_and_set_c_compiler_flag_global(-g)
test_and_set_c_compiler_flag_global(-fsanitize=thread)
elseif (CMAKE_BUILD_TYPE STREQUAL "DebugLSan")
+ test_and_set_c_compiler_flag_global(-g)
test_and_set_c_compiler_flag_global(-fsanitize=leak)
+elseif (CMAKE_BUILD_TYPE STREQUAL "DebugUSan")
+ test_and_set_c_compiler_flag_global(-g)
+ test_and_set_c_compiler_flag_global(-fsanitize=undefined)
+elseif (CMAKE_BUILD_TYPE STREQUAL "DebugAnalyzer")
+ test_and_set_c_compiler_flag_global(-g)
+ test_and_set_c_compiler_flag_global(-fanalyzer)
+else ()
+ message(FATAL_ERROR "Unkown build type ${CMAKE_BUILD_TYPE}")
endif ()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ouroboros-dev.pc.in"
@@ -109,12 +129,29 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ouroboros-dev.pc"
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ouroboros-irm.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
-if (IS_DIRECTORY "/usr/lib/systemd")
- configure_file("${CMAKE_CURRENT_SOURCE_DIR}/irmd.service.in"
- "${CMAKE_CURRENT_BINARY_DIR}/irmd.service" @ONLY)
-
- install(FILES "${CMAKE_CURRENT_BINARY_DIR}/irmd.service"
- DESTINATION "${CMAKE_INSTALL_LIBDIR}/systemd/system")
+# modified from https://github.com/ximion/limba
+pkg_check_modules(SYSTEMD "systemd")
+if (SYSTEMD_FOUND)
+ if ("${SYSTEMD_UNITDIR}" STREQUAL "")
+ execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE}
+ --variable=systemdsystemunitdir systemd
+ OUTPUT_VARIABLE SYSTEMD_UNITDIR)
+ string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_UNITDIR
+ "${SYSTEMD_UNITDIR}"
+ )
+ endif ()
+ if (NOT ${SYSTEMD_UNITDIR} STREQUAL "")
+ message(STATUS "Installing systemd service in: ${SYSTEMD_UNITDIR}")
+ if (LIBTOML_LIBRARIES AND NOT DISABLE_CONFIGFILE)
+ set (CONFIGURE_STRING "--config ${OUROBOROS_CONFIG_DIR}${OUROBOROS_CONFIG_FILE}")
+ else ()
+ set (CONFIGURE_STRING "")
+ endif ()
+ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ouroboros.service.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/ouroboros.service" @ONLY)
+ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ouroboros.service"
+ DESTINATION "${SYSTEMD_UNITDIR}")
+ endif ()
endif ()
enable_testing()