forked from schrodinger/maeparser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
95 lines (77 loc) · 2.99 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
set (CMAKE_CXX_STANDARD 11)
cmake_minimum_required(VERSION 3.5)
project(maeparser)
option(MAEPARSER_RIGOROUS_BUILD "Abort the build if the compiler issues any warnings" OFF )
option(MAEPARSER_BUILD_TESTS "Whether test executables should be built" ON)
option(MAEPARSER_BUILD_SHARED_LIBS "Build maeparser as a shared library (turn off for a static one)" ON)
if(MSVC)
# C4251 disables warnings for export STL containers as arguments (returning a vector of things)
add_compile_options(/wd4251 /wd4275 /wd4996 /D_SCL_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS)
add_definitions(-DBOOST_ALL_NO_LIB)
endif(MSVC)
if(MAEPARSER_RIGOROUS_BUILD)
if(MSVC)
add_compile_options(/WX)
else(MSVC)
add_compile_options(-Wall -Wextra -Werror)
endif(MSVC)
endif(MAEPARSER_RIGOROUS_BUILD)
file(GLOB mae_sources "*.cpp")
if(MAEPARSER_BUILD_SHARED_LIBS)
add_library(maeparser SHARED ${mae_sources})
target_compile_definitions(maeparser PRIVATE "IN_MAEPARSER")
target_compile_definitions(maeparser PRIVATE "BOOST_ALL_DYN_LINK")
set_property(TARGET maeparser PROPERTY CXX_VISIBILITY_PRESET "hidden")
else(MAEPARSER_BUILD_SHARED_LIBS)
set(Boost_USE_STATIC_LIBS ON)
if(NOT MSVC)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
endif()
add_library(maeparser STATIC ${mae_sources})
target_compile_definitions(maeparser PRIVATE "STATIC_MAEPARSER")
endif(MAEPARSER_BUILD_SHARED_LIBS)
find_package(Boost COMPONENTS iostreams REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
set(boost_libs ${Boost_LIBRARIES})
find_package(Boost COMPONENTS zlib QUIET)
if(Boost_ZLIB_FOUND)
set(boost_libs ${boost_libs} ${Boost_LIBRARIES})
message(STATUS "Using Boost zlib module for iostreams dependency.")
else(Boost_ZLIB_FOUND)
find_package(ZLIB REQUIRED)
set(boost_libs ${boost_libs} ${ZLIB_LIBRARIES})
message(STATUS "Using zlib library for iostreams dependency.")
endif(Boost_ZLIB_FOUND)
target_link_libraries(maeparser ${boost_libs})
SET_TARGET_PROPERTIES (maeparser
PROPERTIES
VERSION 1.2.4
SOVERSION 1
)
target_include_directories(maeparser PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>)
if(MSVC)
set(CMAKE_INSTALL_LIBDIR lib)
set(CMAKE_INSTALL_BINDIR bin)
else(MSVC)
include(GNUInstallDirs)
endif(MSVC)
install(TARGETS maeparser
EXPORT maeparser-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
INSTALL(EXPORT maeparser-targets
FILE ${PROJECT_NAME}-config.cmake
DESTINATION lib/cmake)
file(GLOB mae_headers "*.hpp")
install(FILES ${mae_headers} DESTINATION include/maeparser)
# Tests
if (MAEPARSER_BUILD_TESTS)
set(MEMORYCHECK_COMMAND_OPTIONS "${MEMORYCHECK_COMMAND_OPTIONS} --tool=memcheck \
--time-stamp=yes --num-callers=20 --gen-suppressions=all --leak-check=full \
--show-reachable=yes --trace-children=yes --error-exitcode=29")
include(CTest)
add_subdirectory(test)
endif()