mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2024-11-12 17:35:35 +00:00
compiler flags and warning cleanup
This commit is contained in:
parent
f4dcadd3bb
commit
7d55fc30b5
@ -6,15 +6,32 @@ project(
|
|||||||
LANGUAGES C CXX)
|
LANGUAGES C CXX)
|
||||||
|
|
||||||
# includes
|
# includes
|
||||||
|
include(CheckCXXCompilerFlag)
|
||||||
include(CMakePackageConfigHelpers)
|
include(CMakePackageConfigHelpers)
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
include(FindPackageMessage)
|
include(FindPackageMessage)
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
# C++ standard
|
# C++ compile flags
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
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
|
# installation rpath setup
|
||||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
|
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
|
||||||
@ -30,8 +47,8 @@ if(NOT eigen3_POPULATED)
|
|||||||
FetchContent_Populate(Eigen3)
|
FetchContent_Populate(Eigen3)
|
||||||
message(STATUS "Eigen3 fetched")
|
message(STATUS "Eigen3 fetched")
|
||||||
endif()
|
endif()
|
||||||
file(CREATE_LINK ${eigen3_SOURCE_DIR}/Eigen ${CMAKE_SOURCE_DIR}/lib/LatAnalyze/Eigen
|
file(CREATE_LINK ${eigen3_SOURCE_DIR}/Eigen
|
||||||
SYMBOLIC)
|
${CMAKE_SOURCE_DIR}/lib/LatAnalyze/Eigen SYMBOLIC)
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
find_package(GSL REQUIRED)
|
find_package(GSL REQUIRED)
|
||||||
|
@ -17,5 +17,5 @@ set(EXAMPLES_STEM
|
|||||||
|
|
||||||
foreach(_stem ${EXAMPLES_STEM})
|
foreach(_stem ${EXAMPLES_STEM})
|
||||||
add_executable(${_stem} ${_stem}.cpp)
|
add_executable(${_stem} ${_stem}.cpp)
|
||||||
target_link_libraries(${_stem} LatAnalyze)
|
target_link_libraries(${_stem} LatAnalyze compiler_flags)
|
||||||
endforeach()
|
endforeach()
|
||||||
|
@ -33,6 +33,18 @@ flex_target(MathLexer LatAnalyze/Core/MathLexer.lpp
|
|||||||
${CMAKE_CURRENT_BINARY_DIR}/MathLexer.cpp)
|
${CMAKE_CURRENT_BINARY_DIR}/MathLexer.cpp)
|
||||||
add_flex_bison_dependency(MathLexer MathParser)
|
add_flex_bison_dependency(MathLexer MathParser)
|
||||||
|
|
||||||
|
# intermediate libraries
|
||||||
|
add_library(parsers STATIC)
|
||||||
|
target_include_directories(parsers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
target_sources(
|
||||||
|
parsers PRIVATE ${BISON_AsciiParser_OUTPUTS} ${FLEX_AsciiLexer_OUTPUTS}
|
||||||
|
${BISON_MathParser_OUTPUTS} ${FLEX_MathLexer_OUTPUTS})
|
||||||
|
|
||||||
|
add_library(tinyxml2 STATIC)
|
||||||
|
target_include_directories(parsers PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
target_sources(tinyxml2 PRIVATE LatAnalyze/Io/Xml/tinyxml2.hpp
|
||||||
|
LatAnalyze/Io/Xml/tinyxml2.cpp)
|
||||||
|
|
||||||
# library target
|
# library target
|
||||||
add_library(LatAnalyze SHARED)
|
add_library(LatAnalyze SHARED)
|
||||||
file(GLOB_RECURSE EIGEN_HEADERS LatAnalyze/Eigen/*)
|
file(GLOB_RECURSE EIGEN_HEADERS LatAnalyze/Eigen/*)
|
||||||
@ -40,9 +52,7 @@ target_include_directories(LatAnalyze PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
|||||||
include(source-list.cmake)
|
include(source-list.cmake)
|
||||||
target_sources(
|
target_sources(
|
||||||
LatAnalyze
|
LatAnalyze
|
||||||
PRIVATE ${BISON_AsciiParser_OUTPUTS} ${FLEX_AsciiLexer_OUTPUTS}
|
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/config.h ${LATAN_SOURCES}
|
||||||
${BISON_MathParser_OUTPUTS} ${FLEX_MathLexer_OUTPUTS}
|
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/config.h ${LATAN_SOURCES}
|
|
||||||
PUBLIC FILE_SET
|
PUBLIC FILE_SET
|
||||||
public_headers
|
public_headers
|
||||||
TYPE
|
TYPE
|
||||||
@ -50,6 +60,7 @@ target_sources(
|
|||||||
FILES
|
FILES
|
||||||
${EIGEN_HEADERS}
|
${EIGEN_HEADERS}
|
||||||
${LATAN_HEADERS})
|
${LATAN_HEADERS})
|
||||||
|
target_link_libraries(LatAnalyze PRIVATE compiler_flags parsers tinyxml2)
|
||||||
target_link_libraries(LatAnalyze PUBLIC GSL::gsl hdf5::hdf5 hdf5::hdf5_cpp)
|
target_link_libraries(LatAnalyze PUBLIC GSL::gsl hdf5::hdf5 hdf5::hdf5_cpp)
|
||||||
if(Minuit2_FOUND)
|
if(Minuit2_FOUND)
|
||||||
target_link_libraries(LatAnalyze PUBLIC Minuit2::Minuit2)
|
target_link_libraries(LatAnalyze PUBLIC Minuit2::Minuit2)
|
||||||
|
@ -76,7 +76,6 @@ set(LATAN_SOURCES
|
|||||||
LatAnalyze/Io/File.cpp
|
LatAnalyze/Io/File.cpp
|
||||||
LatAnalyze/Io/Hdf5File.cpp
|
LatAnalyze/Io/Hdf5File.cpp
|
||||||
LatAnalyze/Io/Io.cpp
|
LatAnalyze/Io/Io.cpp
|
||||||
LatAnalyze/Io/Xml/tinyxml2.cpp
|
|
||||||
LatAnalyze/Io/XmlReader.cpp
|
LatAnalyze/Io/XmlReader.cpp
|
||||||
LatAnalyze/Numerical/DWT.cpp
|
LatAnalyze/Numerical/DWT.cpp
|
||||||
LatAnalyze/Numerical/DWTFilters.cpp
|
LatAnalyze/Numerical/DWTFilters.cpp
|
||||||
|
@ -376,10 +376,10 @@ int main(int argc, char *argv[])
|
|||||||
unsigned int k = 0;
|
unsigned int k = 0;
|
||||||
while (k < 10)
|
while (k < 10)
|
||||||
{
|
{
|
||||||
auto &f = it->second;
|
auto &itFit = it->second;
|
||||||
|
|
||||||
cout << "#" << k + 1 << " -- [" << f.tMin << ", " << f.tMax << "] -- ";
|
cout << "#" << k + 1 << " -- [" << itFit.tMin << ", " << itFit.tMax << "] -- ";
|
||||||
f.result.print();
|
itFit.result.print();
|
||||||
cout << endl;
|
cout << endl;
|
||||||
k++;
|
k++;
|
||||||
it++;
|
it++;
|
||||||
|
@ -2,6 +2,6 @@ set(PHYSICS_STEM 2pt-fit)
|
|||||||
|
|
||||||
foreach(_stem ${PHYSICS_STEM})
|
foreach(_stem ${PHYSICS_STEM})
|
||||||
add_executable(latan-${_stem} ${_stem}.cpp)
|
add_executable(latan-${_stem} ${_stem}.cpp)
|
||||||
target_link_libraries(latan-${_stem} LatAnalyze)
|
target_link_libraries(latan-${_stem} LatAnalyze compiler_flags)
|
||||||
install(TARGETS latan-${_stem} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
install(TARGETS latan-${_stem} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
@ -13,6 +13,6 @@ set(UTILS_STEM
|
|||||||
|
|
||||||
foreach(_stem ${UTILS_STEM})
|
foreach(_stem ${UTILS_STEM})
|
||||||
add_executable(latan-${_stem} ${_stem}.cpp)
|
add_executable(latan-${_stem} ${_stem}.cpp)
|
||||||
target_link_libraries(latan-${_stem} LatAnalyze)
|
target_link_libraries(latan-${_stem} LatAnalyze compiler_flags)
|
||||||
install(TARGETS latan-${_stem} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
install(TARGETS latan-${_stem} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
Loading…
Reference in New Issue
Block a user