forked from schrodinger/coordgenlibs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
146 lines (127 loc) · 4.46 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
cmake_minimum_required(VERSION 3.2)
project(coordgen)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# Options
option(COORDGEN_RIGOROUS_BUILD "Abort the build if the compiler issues \
any warnings" ON )
option(COORDGEN_BUILD_TESTS "Whether test executables should be built" ON)
option(COORDGEN_BUILD_EXAMPLE "Whether to build the sample executable" ON)
option(COORDGEN_USE_MAEPARSER "Whether to allow loading of run-time templates" OFF)
option(COORDGEN_BUILD_SHARED_LIBS "Build coordgen as a shared library \
(turn off for a static one)" ON)
option(DEBUG_COORDS "Whether to print minimization data and atom mapping to file" OFF)
# Use the maeparser_DIR variable to tell CMake where to search for the
# maeparser library.
if (COORDGEN_USE_MAEPARSER OR COORDGEN_BUILD_TESTS)
set(USE_MAEPARSER ON)
else()
set(USE_MAEPARSER OFF)
endif()
if (USE_MAEPARSER)
set(MAEPARSER_VERSION "master" CACHE STRING "maeparser tag to build if \
a compiled library is not found")
endif()
if(MSVC)
# C4251 disables warnings for export STL containers as arguments
# (returning a vector of things)
add_definitions(/wd4251 /wd4275 /wd4996 /D_SCL_SECURE_NO_WARNINGS
/D_CRT_SECURE_NO_WARNINGS)
add_definitions(-DBOOST_ALL_NO_LIB)
endif(MSVC)
if(COORDGEN_RIGOROUS_BUILD)
if(MSVC)
add_definitions(/WX)
else(MSVC)
add_definitions(-Wall -Wextra -Werror)
endif(MSVC)
endif(COORDGEN_RIGOROUS_BUILD)
# Source files & headers
file(GLOB SOURCES "*.cpp")
# Build Targets & Configuration -- coordgen library
if(COORDGEN_BUILD_SHARED_LIBS)
add_library(coordgen SHARED ${SOURCES})
target_compile_definitions(coordgen PRIVATE "IN_COORDGEN")
set_property(TARGET coordgen PROPERTY CXX_VISIBILITY_PRESET "hidden")
else(COORDGEN_BUILD_SHARED_LIBS)
add_library(coordgen STATIC ${SOURCES})
if (USE_MAEPARSER)
target_compile_definitions(coordgen PRIVATE "STATIC_MAEPARSER")
endif(USE_MAEPARSER)
target_compile_definitions(coordgen PRIVATE "STATIC_COORDGEN")
endif(COORDGEN_BUILD_SHARED_LIBS)
if (DEBUG_COORDS)
target_compile_definitions(coordgen PRIVATE "DEBUG_MINIMIZATION_COORDINATES")
endif()
# Dependencies
if (USE_MAEPARSER)
if(TARGET maeparser)
message(STATUS "Using externally defined maeparser target to "
"build coordgen")
else()
include(CoordgenUtils)
set(MAEPARSER_BUILD_SHARED_LIBS ${COORDGEN_BUILD_SHARED_LIBS} CACHE BOOL "Library type for maeparser")
find_or_clone_maeparser()
endif()
include_directories(${maeparser_INCLUDE_DIRS})
find_package(Boost REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
endif (USE_MAEPARSER)
if (COORDGEN_USE_MAEPARSER)
target_link_libraries(coordgen ${maeparser_LIBRARIES})
target_compile_definitions(coordgen PRIVATE "USE_MAEPARSER")
endif()
set_target_properties(coordgen
PROPERTIES
VERSION 3.0.0
SOVERSION 3
)
if(MSVC)
set(CMAKE_INSTALL_LIBDIR lib)
set(CMAKE_INSTALL_BINDIR bin)
else(MSVC)
include(GNUInstallDirs)
endif(MSVC)
# Install configuration
install(TARGETS coordgen
EXPORT coordgen-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES
CoordgenConfig.hpp
CoordgenFragmentBuilder.h
CoordgenFragmenter.h
CoordgenMacrocycleBuilder.h
CoordgenMinimizer.h
sketcherMinimizerAtom.h
sketcherMinimizerBendInteraction.h
sketcherMinimizerBond.h
sketcherMinimizerClashInteraction.h
sketcherMinimizerEZConstrainInteraction.h
sketcherMinimizerFragment.h
sketcherMinimizer.h
sketcherMinimizerInteraction.h
sketcherMinimizerMarchingSquares.h
sketcherMinimizerMaths.h
sketcherMinimizerMolecule.h
sketcherMinimizerResidue.h
sketcherMinimizerResidueInteraction.h
sketcherMinimizerRing.h
sketcherMinimizerStretchInteraction.h
DESTINATION include/coordgen)
install(EXPORT coordgen-targets
FILE ${PROJECT_NAME}-config.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake)
# Example
if(COORDGEN_BUILD_EXAMPLE)
add_subdirectory(example_dir)
endif(COORDGEN_BUILD_EXAMPLE)
# Tests
if(COORDGEN_BUILD_TESTS)
set(MEMORYCHECK_COMMAND_OPTIONS "--tool=memcheck --time-stamp=yes \
--num-callers=20 --gen-suppressions=all --leak-check=full \
--show-reachable=no --trace-children=yes --error-exitcode=29")
include(CTest)
add_subdirectory(test)
endif(COORDGEN_BUILD_TESTS)