Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue #13: reworked CMakeLists.txt #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
50 changes: 35 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.8.2 FATAL_ERROR)

project(boost_matheval CXX)

include(GNUInstallDirs)

# Default build type is Debug
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the build type" FORCE)
Expand All @@ -21,31 +23,49 @@ if(WITH_COVERAGE)
endif()
endif()

if(CMAKE_VERSION VERSION_GREATER 3.5.2 AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
option(WITH_CLANG_TIDY "Run Clang-Tidy during compilation" OFF)
endif()
if(WITH_CLANG_TIDY)
string(REGEX REPLACE "^([1-9]+\\.[0-9]+).*$" "\\1" CLANG_MINOR_VERSION "${CMAKE_CXX_COMPILER_VERSION}")
find_program(
option(WITH_CLANG_TIDY "Run Clang-Tidy during compilation" OFF)

# Find clang-tidy executable (no matter if building with gcc or clang)
string(REGEX REPLACE "^([1-9]+\\.[0-9]+).*$" "\\1" CLANG_MINOR_VERSION "${CMAKE_CXX_COMPILER_VERSION}")
find_program(
CLANG_TIDY_EXE
NAMES "clang-tidy-${CLANG_MINOR_VERSION}" "clang-tidy"
DOC "Path to clang-tidy executable"
)
)

if(WITH_CLANG_TIDY)
if(NOT CLANG_TIDY_EXE)
message(STATUS "clang-tidy not found.")
message(FATAL_ERROR "clang-tidy was enabled but no executable found.")
else()
message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}"
"-checks=-*,bugprone-*,cert-*,clang-analyzer-*,cppcoreguidelines-*,hicpp-*,misc-*,modernize-*,performance-*,readability-*"
"-header-filter=.*")
#"-warnings-as-errors=*")
"-header-filter=.*"
"-warnings-as-errors=*"
)
endif()
endif()


# Subdirectories
add_subdirectory(src/qi)
add_subdirectory(src/x3)
add_subdirectory(doc/doxygen)
add_subdirectory(examples)
add_subdirectory(tests)



# Install
install(
DIRECTORY include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.hpp"
)

install(
EXPORT ${PROJECT_NAME}
NAMESPACE matheval::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}/
)

add_subdirectory(src/qi EXCLUDE_FROM_ALL)
add_subdirectory(src/x3 EXCLUDE_FROM_ALL)
add_subdirectory(doc/doxygen EXCLUDE_FROM_ALL)
add_subdirectory(examples EXCLUDE_FROM_ALL)
add_subdirectory(tests EXCLUDE_FROM_ALL)
2 changes: 1 addition & 1 deletion cmake/FindReadline.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ find_path(READLINE_INCLUDE_DIR NAMES readline/readline.h)

find_library(READLINE_LIBRARY NAMES readline)

find_package_handle_standard_args(READLINE DEFAULT_MSG READLINE_LIBRARY READLINE_INCLUDE_DIR)
find_package_handle_standard_args(Readline DEFAULT_MSG READLINE_LIBRARY READLINE_INCLUDE_DIR)

mark_as_advanced(READLINE_INCLUDE_DIR READLINE_LIBRARY)
49 changes: 32 additions & 17 deletions src/qi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,37 @@
find_package(Boost 1.65.1 REQUIRED)

add_library(matheval.qi
ast_adapted.hpp
ast.hpp
evaluator.cpp
evaluator.hpp
matheval.cpp
math.hpp
parser.cpp
parser_def.hpp
parser.hpp
)
ast_adapted.hpp
ast.hpp
evaluator.cpp
evaluator.hpp
matheval.cpp
math.hpp
parser.cpp
parser_def.hpp
parser.hpp
)
target_include_directories(matheval.qi
PUBLIC ../../include/matheval/qi
)
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../include/matheval/qi>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/matheval/qi>
)
target_compile_features(matheval.qi
PUBLIC cxx_std_98
)
find_package(Boost 1.65.1 REQUIRED)
PUBLIC
cxx_std_98
)
target_link_libraries(matheval.qi
PRIVATE Boost::boost
)
PUBLIC
Boost::boost
)

set_target_properties(matheval.qi PROPERTIES EXPORT_NAME qi)

add_library(matheval::qi ALIAS matheval.qi)

install(
TARGETS matheval.qi
DESTINATION ${CMAKE_INSTALL_LIBDIR}
EXPORT ${PROJECT_NAME}
)

48 changes: 31 additions & 17 deletions src/x3/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
find_package(Boost 1.65.1 REQUIRED)

add_library(matheval.x3
ast_adapted.hpp
ast.hpp
evaluator.cpp
evaluator.hpp
matheval.cpp
math.hpp
parser.cpp
parser_def.hpp
parser.hpp
)
ast_adapted.hpp
ast.hpp
evaluator.cpp
evaluator.hpp
matheval.cpp
math.hpp
parser.cpp
parser_def.hpp
parser.hpp
)
target_include_directories(matheval.x3
PUBLIC ../../include/matheval/x3
)
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../include/matheval/x3>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/matheval/x3>
)
target_compile_features(matheval.x3
PUBLIC cxx_std_14
)
find_package(Boost 1.65.1 REQUIRED)
PUBLIC
cxx_std_14
)
target_link_libraries(matheval.x3
PRIVATE Boost::boost
)
PUBLIC
Boost::boost
)

set_target_properties(matheval.x3 PROPERTIES EXPORT_NAME x3)

add_library(matheval::x3 ALIAS matheval.x3)

install(
TARGETS matheval.x3
DESTINATION ${CMAKE_INSTALL_LIBDIR}
EXPORT ${PROJECT_NAME}
)