forked from openbabel/openbabel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
145 lines (128 loc) · 3.97 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
if(MINIMAL_BUILD)
set(tools
obabel
)
else(MINIMAL_BUILD)
find_package(Boost COMPONENTS program_options iostreams)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS} ${Boost_INCLUDE_DIR})
endif()
set(tools
obabel
obconformer
obenergy
obfit
obfitall
obgen
obminimize
obmm
obprobe
obprop
obrotamer
obrotate
obsym
obtautomer
obthermo
)
if(EIGEN3_FOUND)
set(tools
${tools}
obdistgen
)
endif()
endif(MINIMAL_BUILD)
INCLUDE(CheckFunctionExists)
SET(GETOPT getopt)
CHECK_FUNCTION_EXISTS(${GETOPT} GETOPT_FOUND)
if(BUILD_SHARED)
foreach(tool ${tools})
add_executable(${tool} ${tool}.cpp)
target_link_libraries(${tool} ${BABEL_LIBRARY})
install(TARGETS ${tool}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX}
)
endforeach(tool)
if(NOT MINIMAL_BUILD)
# obgrep, obrms, obspectrophore -- require getopt
set(toolnames obgrep obspectrophore)
if(EIGEN3_FOUND)
set(toolnames ${toolnames} obrms)
endif()
foreach(tool ${toolnames})
if (NOT GETOPT_FOUND)
add_executable(${tool} ${tool}.cpp getopt.c)
else(NOT GETOPT_FOUND)
add_executable(${tool} ${tool}.cpp)
endif(NOT GETOPT_FOUND)
target_link_libraries(${tool} ${BABEL_LIBRARY})
install(TARGETS ${tool}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX}
)
endforeach()
endif(NOT MINIMAL_BUILD)
else(BUILD_SHARED)
###############################################################################
#
# Build STATIC obabel with all plugins taken from the static libopenbabel.a
#
###############################################################################
# Set libs to imported openbabel target
set(libs openbabel)
if(WITH_STATIC_INCHI)
set(libs ${libs} ${INCHI_LIBRARY})
endif()
if(WITH_STATIC_LIBXML)
set(libs ${libs} ${LIBXML2_LIBRARIES})
endif()
if(NOT MSVC)
find_package(Threads)
if(BUILD_MIXED)
list(APPEND libs Threads::Threads)
elseif(CMAKE_USE_PTHREADS_INIT)
# Make sure to find the static library
find_library(PTHREAD_LIBRARY NAMES pthread)
list(APPEND libs ${PTHREAD_LIBRARY})
endif()
if(BUILD_MIXED)
if(CMAKE_COMPILER_IS_GNUCXX)
if(CMAKE_SYSTEM_NAME MATCHES Linux)
#
# Relocatable binaries on linux using -static-libgcc. (GCC only)
#
set(CMAKE_CXX_FLAGS "-static-libgcc ${CMAKE_CXX_FLAGS}")
# make sure the linker will find the static libstdc++
file(REMOVE "${CMAKE_BINARY_DIR}/libstdc++.a")
execute_process(COMMAND "g++" "-print-file-name=libstdc++.a"
OUTPUT_VARIABLE libstdcpp
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND "ln" "-s" "${libstdcpp}"
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
link_directories(${CMAKE_BINARY_DIR})
endif(CMAKE_SYSTEM_NAME MATCHES Linux)
endif(CMAKE_COMPILER_IS_GNUCXX)
else(BUILD_MIXED)
#
# Default static build using GNU-like compiler.
#
if (NOT APPLE)
set(CMAKE_CXX_FLAGS "-static ${CMAKE_CXX_FLAGS}")
endif()
# APPLE doesn't use -static
endif(BUILD_MIXED)
endif()
# build a static obabel only
add_executable(obabel obabel.cpp)
target_link_libraries(obabel ${libs})
if(NOT BUILD_MIXED)
# Prevent -Wl,-Bdynamic from being added to the end of the link line.
set_target_properties(obabel PROPERTIES LINK_SEARCH_END_STATIC TRUE)
endif(NOT BUILD_MIXED)
install(TARGETS obabel
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib${LIB_SUFFIX}
ARCHIVE DESTINATION lib${LIB_SUFFIX})
endif(BUILD_SHARED)