mirror of
https://github.com/aportelli/LatAnalyze.git
synced 2024-11-10 00:45:36 +00:00
compiler flags and warning cleanup
This commit is contained in:
parent
f4dcadd3bb
commit
7d55fc30b5
@ -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)
|
||||
|
@ -17,5 +17,5 @@ set(EXAMPLES_STEM
|
||||
|
||||
foreach(_stem ${EXAMPLES_STEM})
|
||||
add_executable(${_stem} ${_stem}.cpp)
|
||||
target_link_libraries(${_stem} LatAnalyze)
|
||||
target_link_libraries(${_stem} LatAnalyze compiler_flags)
|
||||
endforeach()
|
||||
|
@ -33,6 +33,18 @@ flex_target(MathLexer LatAnalyze/Core/MathLexer.lpp
|
||||
${CMAKE_CURRENT_BINARY_DIR}/MathLexer.cpp)
|
||||
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
|
||||
add_library(LatAnalyze SHARED)
|
||||
file(GLOB_RECURSE EIGEN_HEADERS LatAnalyze/Eigen/*)
|
||||
@ -40,9 +52,7 @@ target_include_directories(LatAnalyze PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
include(source-list.cmake)
|
||||
target_sources(
|
||||
LatAnalyze
|
||||
PRIVATE ${BISON_AsciiParser_OUTPUTS} ${FLEX_AsciiLexer_OUTPUTS}
|
||||
${BISON_MathParser_OUTPUTS} ${FLEX_MathLexer_OUTPUTS}
|
||||
${CMAKE_CURRENT_BINARY_DIR}/config.h ${LATAN_SOURCES}
|
||||
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/config.h ${LATAN_SOURCES}
|
||||
PUBLIC FILE_SET
|
||||
public_headers
|
||||
TYPE
|
||||
@ -50,6 +60,7 @@ target_sources(
|
||||
FILES
|
||||
${EIGEN_HEADERS}
|
||||
${LATAN_HEADERS})
|
||||
target_link_libraries(LatAnalyze PRIVATE compiler_flags parsers tinyxml2)
|
||||
target_link_libraries(LatAnalyze PUBLIC GSL::gsl hdf5::hdf5 hdf5::hdf5_cpp)
|
||||
if(Minuit2_FOUND)
|
||||
target_link_libraries(LatAnalyze PUBLIC Minuit2::Minuit2)
|
||||
|
@ -76,7 +76,6 @@ set(LATAN_SOURCES
|
||||
LatAnalyze/Io/File.cpp
|
||||
LatAnalyze/Io/Hdf5File.cpp
|
||||
LatAnalyze/Io/Io.cpp
|
||||
LatAnalyze/Io/Xml/tinyxml2.cpp
|
||||
LatAnalyze/Io/XmlReader.cpp
|
||||
LatAnalyze/Numerical/DWT.cpp
|
||||
LatAnalyze/Numerical/DWTFilters.cpp
|
||||
|
@ -376,10 +376,10 @@ int main(int argc, char *argv[])
|
||||
unsigned int k = 0;
|
||||
while (k < 10)
|
||||
{
|
||||
auto &f = it->second;
|
||||
auto &itFit = it->second;
|
||||
|
||||
cout << "#" << k + 1 << " -- [" << f.tMin << ", " << f.tMax << "] -- ";
|
||||
f.result.print();
|
||||
cout << "#" << k + 1 << " -- [" << itFit.tMin << ", " << itFit.tMax << "] -- ";
|
||||
itFit.result.print();
|
||||
cout << endl;
|
||||
k++;
|
||||
it++;
|
||||
|
@ -2,6 +2,6 @@ set(PHYSICS_STEM 2pt-fit)
|
||||
|
||||
foreach(_stem ${PHYSICS_STEM})
|
||||
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})
|
||||
endforeach()
|
||||
|
@ -13,6 +13,6 @@ set(UTILS_STEM
|
||||
|
||||
foreach(_stem ${UTILS_STEM})
|
||||
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})
|
||||
endforeach()
|
||||
|
Loading…
Reference in New Issue
Block a user