diff --git a/CMakeLists.txt b/CMakeLists.txt index a1edf935..51b45f44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,9 +9,6 @@ project(maliput_malidrive LANGUAGES C CXX VERSION 1.0.0) # CMake Support ############################################################################## -# Useful string/list macros -include (${PROJECT_SOURCE_DIR}/cmake/Utils.cmake) - # Set CMAKE_INSTALL_ include(GNUInstallDirs) @@ -33,7 +30,8 @@ find_package(maliput_drake REQUIRED) message(STATUS "\n\n========= Project Configuration ========\n") -include(${PROJECT_SOURCE_DIR}/cmake/MaliputMalidriveFlags.cmake) +include(${PROJECT_SOURCE_DIR}/cmake/DefaultCFlags.cmake) +include(${PROJECT_SOURCE_DIR}/cmake/SanitizersConfig.cmake) set(BUILD_SHARED_LIBS true) diff --git a/cmake/DefaultCFlags.cmake b/cmake/DefaultCFlags.cmake index 92dc500a..afe3e1a2 100644 --- a/cmake/DefaultCFlags.cmake +++ b/cmake/DefaultCFlags.cmake @@ -1,42 +1,3 @@ -# Note that we have to put '-rdynamic' into all of the LINK_FLAGS so that -# we get our symbols placed into the dynamic symbol table. This is needed so -# that our loadable agents have access to the internal symbols from our library. - -# Build type link flags -set (CMAKE_LINK_FLAGS_RELEASE " -rdynamic" CACHE INTERNAL "Link flags for release" FORCE) -set (CMAKE_LINK_FLAGS_RELWITHDEBINFO " -rdynamic" CACHE INTERNAL "Link flags for release with debug support" FORCE) -set (CMAKE_LINK_FLAGS_DEBUG " -rdynamic" CACHE INTERNAL "Link flags for debug" FORCE) -set (CMAKE_LINK_FLAGS_PROFILE " -rdynamic -pg" CACHE INTERNAL "Link flags for profile" FORCE) - -set (CMAKE_C_FLAGS_RELEASE "") -set (CMAKE_C_FLAGS_RELEASE "-s") - -set (CMAKE_C_FLAGS_RELEASE " ${CMAKE_C_FLAGS_RELEASE} -O3 -DNDEBUG ${CMAKE_C_FLAGS_ALL}" CACHE INTERNAL "C Flags for release" FORCE) -set (CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE}) - -set (CMAKE_C_FLAGS_RELWITHDEBINFO " -g -O2 ${CMAKE_C_FLAGS_ALL}" CACHE INTERNAL "C Flags for release with debug support" FORCE) -set (CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO}) - -set (CMAKE_C_FLAGS_DEBUG " -ggdb3 ${CMAKE_C_FLAGS_ALL}" CACHE INTERNAL "C Flags for debug" FORCE) -set (CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG}) - -set (CMAKE_C_FLAGS_PROFILE " -fno-omit-frame-pointer -g -pg ${CMAKE_C_FLAGS_ALL}" CACHE INTERNAL "C Flags for profile" FORCE) -set (CMAKE_CXX_FLAGS_PROFILE ${CMAKE_C_FLAGS_PROFILE}) - -##################################### -# Set all the global build flags -set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}") -set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}") -set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}") -set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}") - -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}} -std=c++17") - -set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}") -set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}") -set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}") -set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_LINK_FLAGS_${CMAKE_BUILD_TYPE_UPPERCASE}}") - # C++ Version set (CMAKE_CXX_STANDARD 17) set (CMAKE_CXX_STANDARD_REQUIRED ON) @@ -49,7 +10,7 @@ if ("${CMAKE_CXX_COMPILER_ID} " MATCHES "GNU ") if (NOT (GCC_VERSION VERSION_GREATER 6.9)) message(FATAL_ERROR "${PROJECT_NAME} requires g++ 7.0 or greater.") else () - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdata-sections -fdiagnostics-color=always -ffunction-sections -fopenmp -fPIC -fstack-protector -fno-omit-frame-pointer -no-canonical-prefixes -O2 -std=c++17 -Wall -Wno-builtin-macro-redefined -Wno-missing-field-initializers -Wregister -Wstrict-overflow -Wno-unused-const-variable") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdata-sections -fdiagnostics-color=always -ffunction-sections -fopenmp -fPIC -fstack-protector -fno-omit-frame-pointer -no-canonical-prefixes -O2 -std=c++17 -Wall -Wno-builtin-macro-redefined -Wno-missing-field-initializers -Wregister -Wstrict-overflow -Wno-unused-const-variable") endif () elseif ("${CMAKE_CXX_COMPILER_ID} " MATCHES "Clang ") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdata-sections -fdiagnostics-color=always -ffunction-sections -fPIC -fstack-protector -fno-omit-frame-pointer -no-canonical-prefixes -O2 -std=c++17 -Wall -Wno-builtin-macro-redefined -Wno-deprecated-dynamic-exception-spec -Wno-enum-compare-switch -Wno-gnu-designator -Wno-missing-field-initializers -Wno-register -Wno-strict-overflow -Wno-unknown-warning-option -Wno-unneeded-internal-declaration -Wno-unused-const-variable -Wno-missing-braces") diff --git a/cmake/MaliputMalidriveFlags.cmake b/cmake/MaliputMalidriveFlags.cmake deleted file mode 100644 index ad751a08..00000000 --- a/cmake/MaliputMalidriveFlags.cmake +++ /dev/null @@ -1,37 +0,0 @@ -##################################### -# Handle CFlags - -unset (CMAKE_C_FLAGS_ALL CACHE) -unset (CMAKE_CXX_FLAGS CACHE) - -include(${PROJECT_SOURCE_DIR}/cmake/DefaultCFlags.cmake) -include(${PROJECT_SOURCE_DIR}/cmake/SanitizersConfig.cmake) - -# Check if warning options are avaliable for the compiler and return WARNING_CXX_FLAGS variable -list(APPEND WARN_LEVEL -Waddress -Warray-bounds -Wcomment -Wformat -Wnonnull) -list(APPEND WARN_LEVEL -Wparentheses -Wreorder -Wreturn-type) -list(APPEND WARN_LEVEL -Wsequence-point -Wsign-compare -Wstrict-aliasing) -list(APPEND WARN_LEVEL -Wstrict-overflow=1 -Wswitch -Wtrigraphs -Wuninitialized) -list(APPEND WARN_LEVEL -Wunused-function -Wunused-label -Wunused-value) -list(APPEND WARN_LEVEL -Wunused-variable -Wvolatile-register-var) - -# Unable to be filtered flags (failing due to limitations in filter_valid_compiler_warnings) -set(UNFILTERED_FLAGS "-Wc++17-compat") - -filter_valid_compiler_warnings(${WARN_LEVEL} -Wextra -Wno-long-long - -Wno-unused-value -Wno-unused-value -Wno-unused-value -Wno-unused-value - -Winit-self -Wswitch-default - -Wmissing-include-dirs -Wno-pragmas) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}${WARNING_CXX_FLAGS} ${UNFILTERED_FLAGS}") - -# Report out -message(STATUS "Shared Libraries..............${BUILD_SHARED_LIBS}") -message(STATUS "Build Type....................${CMAKE_BUILD_TYPE}") -message(STATUS "Install path..................${CMAKE_INSTALL_PREFIX}") -if (DEFINED CMAKE_CXX_FLAGS) - message(STATUS "Custom CFlags.................${CMAKE_CXX_FLAGS}") -else() - message (STATUS "Using default CFlags") -endif() - -message(STATUS "\n----------------------------------------\n") diff --git a/cmake/Utils.cmake b/cmake/Utils.cmake deleted file mode 100644 index f8f97544..00000000 --- a/cmake/Utils.cmake +++ /dev/null @@ -1,40 +0,0 @@ -################################################################################ -# Appends items to a cached list. -macro(append_to_cached_string _string _cacheDesc) - foreach(newItem ${ARGN}) - set(${_string} "${${_string}} ${newItem}" CACHE INTERNAL ${_cacheDesc} FORCE) - endforeach(newItem ${ARGN}) -endmacro(append_to_cached_string) - -################################################################################ -# Appends items to a cached list. -macro(append_to_cached_list _list _cacheDesc) - set(tempList ${${_list}}) - foreach(newItem ${ARGN}) - list(APPEND tempList ${newItem}) - endforeach(newItem ${newItem}) - set(${_list} ${tempList} CACHE INTERNAL ${_cacheDesc} FORCE) -endmacro(append_to_cached_list) - -################################################# -# Macro to turn a list into a string (why doesn't CMake have this built-in?) -macro(list_to_string _string _list) - set(${_string}) - foreach(_item ${_list}) - set(${_string} "${${_string}} ${_item}") - endforeach(_item) -endmacro(list_to_string) - -################################################# -# Macro to setup supported compiler warnings -# Based on work of Florent Lamiraux, Thomas Moulard, JRL, CNRS/AIST. -include(CheckCXXCompilerFlag) - -macro(filter_valid_compiler_warnings) - foreach(flag ${ARGN}) - CHECK_CXX_COMPILER_FLAG(${flag} R${flag}) - if(${R${flag}}) - set(WARNING_CXX_FLAGS "${WARNING_CXX_FLAGS} ${flag}") - endif() - endforeach() -endmacro() diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in deleted file mode 100644 index 2037e365..00000000 --- a/cmake/cmake_uninstall.cmake.in +++ /dev/null @@ -1,21 +0,0 @@ -if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") - message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") -endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") - -file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) -string(REGEX REPLACE "\n" ";" files "${files}") -foreach(file ${files}) - message(STATUS "Uninstalling $ENV{DESTDIR}${file}") - if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") - exec_program( - "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" - OUTPUT_VARIABLE rm_out - RETURN_VALUE rm_retval - ) - if(NOT "${rm_retval}" STREQUAL 0) - message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") - endif(NOT "${rm_retval}" STREQUAL 0) - else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") - message(STATUS "File $ENV{DESTDIR}${file} does not exist.") - endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") -endforeach(file) diff --git a/cmake/malidrive-malidrive-config.cmake.in b/cmake/malidrive-malidrive-config.cmake.in deleted file mode 100644 index 72c7ea72..00000000 --- a/cmake/malidrive-malidrive-config.cmake.in +++ /dev/null @@ -1,25 +0,0 @@ -############################################################################## -# -# For finding and loading @PROJECT_NAME@ from your project, type: -# -# find_package(@PROJECT_NAME@) -# -# It defines the following variables: -# -# @PROJECT_NAME@_FOUND - @PROJECT_NAME@ is available -# @PROJECT_NAME@_IMPORTS - list of imported targets -# -############################################################################## -# NB: Refer to https://cmake.org/cmake/help/v3.5/manual/cmake-packages.7.html -############################################################################## - -@PACKAGE_INIT@ - -include(${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake) - -############################################################################## -# Dependencies -############################################################################## - -include(CMakeFindDependencyMacro) -find_dependency(drake_vendor)