Skip to content

Commit

Permalink
Cmakeupdates (#46)
Browse files Browse the repository at this point in the history
Updates the CMAKE build system by removing some deprecated options and by preparing the code to be included as a subproject to storm. 

Co-authored-by: Matthias Volk <[email protected]>
  • Loading branch information
sjunges and volkm authored Feb 4, 2025
1 parent f479e25 commit 9bb8e64
Show file tree
Hide file tree
Showing 22 changed files with 135 additions and 3,469 deletions.
49 changes: 26 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ set( PROJECT_DESCRIPTION "Computer ARithmetic Library")
set( carl_NAME "CArL" )
set( carl_DESCRIPTION ${PROJECT_DESCRIPTION} )

message(STATUS "Version: ${PROJECT_FULLNAME} ${PROJECT_VERSION_FULL}")
message(STATUS "carl - Version: ${PROJECT_FULLNAME} ${PROJECT_VERSION_FULL}")

# # # # # # # # # # # # # # # # # # # # # #
# B. Options
Expand Down Expand Up @@ -63,7 +63,6 @@ option( USE_BLISS "Use bliss" OFF )
export_option(USE_BLISS)
OPTION( USE_MPFR_FLOAT "Use the mpfr implementation of floating point numbers." OFF )
export_option(USE_MPFR_FLOAT)
option( USE_COTIRE "Use cotire to generate and use precompiled headers" OFF )
option( PORTABLE "Enable portable build without hardware-specific compiler flags." OFF)
export_option(PORTABLE)
option( BUILD_STATIC "Build the static library as well" OFF )
Expand All @@ -76,40 +75,45 @@ option( PRUNE_MONOMIAL_POOL "Prune monomial pool" ON )
option( EXCLUDE_TESTS_FROM_ALL "If set, tests will not be compiled by default" OFF )
export_option(EXCLUDE_TESTS_FROM_ALL)

option (CARL_COMPILE_BENCHMARKS "Compile Benchmarks" OFF)

set(CLANG_SANITIZER "none" CACHE STRING "Compile with the respective sanitizer")
set_property(CACHE CLANG_SANITIZER PROPERTY STRINGS none address memory thread)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

if (NOT CMAKE_BUILD_TYPE)
if (PROJECT_IS_TOP_LEVEL)
set(CMAKE_BUILD_TYPE "RELEASE" CACHE STRING "Build type." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "DEBUG" "RELEASE")
endif()

set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "DEBUG" "RELEASE")

set(CARL_LIBRARIES_DIR "${PROJECT_BINARY_DIR}/lib")

# Offer the user the choice of overriding the installation directories
set(INCLUDE_INSTALL_DIR include/ CACHE PATH "Installation directory for header files" )
set(LIB_INSTALL_DIR lib/ CACHE PATH "Installation directory for libraries")
#set(SYSCONFIG_INSTALL_DIR etc/carl/ CACHE PATH "Installation for system configuration files)
set(BIN_INSTALL_DIR lib/ CACHE PATH "Installation directory for executables")
set(CARL_INCLUDE_INSTALL_DIR include/ CACHE PATH "Installation directory for header files" )
set(CARL_LIB_INSTALL_DIR lib/ CACHE PATH "Installation directory for libraries")
set(CARL_BIN_INSTALL_DIR bin/ CACHE PATH "Installation directory for executables")
set(CARL_CMAKE_INSTALL_DIR lib/cmake/ CACHE PATH "Installation directory for executables")



if(WIN32 AND NOT CYGWIN)
set(DEF_INSTALL_CMAKE_DIR CMake)
else()
set(DEF_INSTALL_CMAKE_DIR lib/cmake/carl)
endif()
set(CMAKE_INSTALL_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files")
if (PROJECT_IS_TOP_LEVEL)
set(CMAKE_INSTALL_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files")
endif()

if(APPLE AND ${CMAKE_SYSTEM_PROCESSOR} MATCHES arm64)
message(STATUS "Detected that target system uses Apple Silicon.")
message(WARNING "Compiling natively on Apple Silicon is experimental. Please report issues to [email protected]. For more information visit https://www.stormchecker.org/documentation/obtain-storm/apple-silicon.html")
message(STATUS "carl - Detected that target system uses Apple Silicon.")
message(WARNING "carl - Compiling natively on Apple Silicon is experimental. Please report issues to [email protected]. For more information visit https://www.stormchecker.org/documentation/obtain-storm/apple-silicon.html")
set(APPLE_SILICON 1)
endif()

foreach(p LIB BIN INCLUDE CMAKE)
set(var ${p}_INSTALL_DIR)
set(var CARL_${p}_INSTALL_DIR)
if(NOT IS_ABSOLUTE "${${var}}")
set(${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
endif()
Expand All @@ -131,16 +135,14 @@ elseif (WIN32)
endif()

if(BUILD_STATIC)
message(STATUS "Building static: yes")
message(STATUS "carl - Building static: yes")
if (LOGGING)
message(WARNING "A static build with logging enabled will probably trigger a segfault!")
message(WARNING "carl - A static build with logging enabled will probably trigger a segfault!")
endif()
else()
message(STATUS "Building static: no")
message(STATUS "carl - Building static: no")
endif()

include(cotire)

# RPATH settings
# don't skip the full RPATH for the build tree
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
Expand Down Expand Up @@ -168,18 +170,19 @@ SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
include(resources/resources.cmake)

# we only search for this libraries in the system, if we do not force using the shipped resources.

enable_testing()
if(PROJECT_IS_TOP_LEVEL)
enable_testing()
include(coverage)
endif()

#dl must be linked LAST as this is required for the stacktrace in util/platform.h
if (NOT WIN32)
list(APPEND carl_LIBRARIES_DYNAMIC pthread dl)
endif()

include(clang-tidy)
include(coverage)

if (TARGET Doxygen::doxygen)
if (TARGET Doxygen::doxygen AND PROJECT_IS_TOP_LEVEL)
include(clang-tidy)
include(resources/doc-resources.cmake)
add_subdirectory(doxygen-conf)
endif()
add_subdirectory(src)
Expand Down
5 changes: 5 additions & 0 deletions cmake/carlmacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ function(set_version major minor patch)
if(patch)
set(PROJECT_VERSION_FULL "${major}.${minor}.${patch_full}" PARENT_SCOPE)
set(PROJECT_VERSION "${major}.${minor}.${patch}" PARENT_SCOPE)

else()
set(PROJECT_VERSION_FULL "${major}.${minor}" PARENT_SCOPE)
set(PROJECT_VERSION "${major}.${minor}" PARENT_SCOPE)
endif()
set(${PROJECT_NAME}_VERSION_MAJOR ${PROJECT_VERSION_MAJOR} PARENT_SCOPE)
set(${PROJECT_NAME}_VERSION_MINOR ${PROJECT_VERSION_MINOR} PARENT_SCOPE)
set(${PROJECT_NAME}_VERSION_PATCH ${PROJECT_VERSION_PATCH} PARENT_SCOPE)

endfunction(set_version)

function(add_imported_library_interface name include)
Expand Down
23 changes: 12 additions & 11 deletions cmake/compiler-options.cmake
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # Matches "Clang" and "AppleClang"
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5)
message(FATAL_ERROR " clang version must be at least 3.5!")
message(FATAL_ERROR "carl - Clang version must be at least 3.5!")
endif()
if (APPLE)
message(STATUS "Using clang ${CMAKE_CXX_COMPILER_VERSION} on Apple")
message(STATUS "carl - Using clang ${CMAKE_CXX_COMPILER_VERSION} on Apple")
set(CMAKE_MACOSX_RPATH 1)
set(CMAKE_MACOSX_RPATH 1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -stdlib=libc++ -pthread")
else()
message(STATUS "Using clang ${CMAKE_CXX_COMPILER_VERSION}")
message(STATUS "carl - Using clang ${CMAKE_CXX_COMPILER_VERSION}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -pthread")
endif()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -fomit-frame-pointer -funroll-loops")
Expand All @@ -17,20 +18,20 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # Matches "Clang" and "AppleClan
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
message(FATAL_ERROR " g++ version must be at least 4.9!")
message(FATAL_ERROR "carl - g++ version must be at least 4.9!")
endif()
message(STATUS "Using g++ ${CMAKE_CXX_COMPILER_VERSION}")
message(STATUS "carl - Using g++ ${CMAKE_CXX_COMPILER_VERSION}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wunknown-pragmas")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -fmax-errors=5 -fdiagnostics-color=auto")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O1")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
message("-- Using Visual Studio C++ ${CMAKE_CXX_COMPILER_VERSION}")
message("carl - Using Visual Studio C++ ${CMAKE_CXX_COMPILER_VERSION}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP1 /D_SCL_SECURE_NO_WARNINGS")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2 /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd /bigobj")
else()
message(WARNING "Possibly unsupported compiler ${CMAKE_CXX_COMPILER_ID}")
message(WARNING "carl - Possibly unsupported compiler ${CMAKE_CXX_COMPILER_ID}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()

Expand Down Expand Up @@ -75,7 +76,7 @@ if(DEVELOPER)
set(CMAKE_BUILD_TYPE "DEBUG")
endif()

message(STATUS "CXX Flags: ${CMAKE_CXX_FLAGS}")
message(STATUS "CXX Debug Flags: ${CMAKE_CXX_FLAGS_DEBUG}")
message(STATUS "CXX Release Flags: ${CMAKE_CXX_FLAGS_RELEASE}")
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "carl - CXX Flags: ${CMAKE_CXX_FLAGS}")
message(STATUS "carl - CXX Debug Flags: ${CMAKE_CXX_FLAGS_DEBUG}")
message(STATUS "carl - CXX Release Flags: ${CMAKE_CXX_FLAGS_RELEASE}")
message(STATUS "carl - Build type: ${CMAKE_BUILD_TYPE}")
Loading

0 comments on commit 9bb8e64

Please sign in to comment.