1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2025-06-20 08:16:55 +01:00

compiler flags and warning cleanup

This commit is contained in:
2024-02-10 12:58:23 +01:00
parent f4dcadd3bb
commit 7d55fc30b5
7 changed files with 40 additions and 13 deletions

View File

@ -6,15 +6,32 @@ project(
LANGUAGES C CXX)
# includes
include(CheckCXXCompilerFlag)
include(CMakePackageConfigHelpers)
include(FetchContent)
include(FindPackageMessage)
include(GNUInstallDirs)
# C++ standard
# C++ compile flags
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS OFF)
check_cxx_compiler_flag("-march=native" COMPILER_SUPPORTS_MARCH_NATIVE)
if(COMPILER_SUPPORTS_MARCH_NATIVE)
set(MARCH_FLAG "-march=native")
endif()
check_cxx_compiler_flag("-mtune=native" COMPILER_SUPPORTS_MTUNE_NATIVE)
if(COMPILER_SUPPORTS_MTUNE_NATIVE)
set(MTUNE_FLAG "-mtune=native")
endif()
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG ${MARCH_FLAG} ${MTUNE_FLAG}")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG ${MARCH_FLAG} ${MTUNE_FLAG}")
set(gcc_like_cxx "$<COMPILE_LANG_AND_ID:CXX,ARMClang,AppleClang,Clang,GNU,LCC>")
add_library(compiler_flags INTERFACE)
target_compile_features(compiler_flags INTERFACE cxx_std_14)
target_compile_options(
compiler_flags
INTERFACE "$<${gcc_like_cxx}:-Wall;-Wextra;-Wshadow;-Wformat=2;-Wunused>")
# installation rpath setup
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
@ -30,8 +47,8 @@ if(NOT eigen3_POPULATED)
FetchContent_Populate(Eigen3)
message(STATUS "Eigen3 fetched")
endif()
file(CREATE_LINK ${eigen3_SOURCE_DIR}/Eigen ${CMAKE_SOURCE_DIR}/lib/LatAnalyze/Eigen
SYMBOLIC)
file(CREATE_LINK ${eigen3_SOURCE_DIR}/Eigen
${CMAKE_SOURCE_DIR}/lib/LatAnalyze/Eigen SYMBOLIC)
# dependencies
find_package(GSL REQUIRED)