summaryrefslogtreecommitdiff
blob: eeec55d4e8e6956c9135025308b6177009327907 (plain)
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# HG changeset patch
# User Christoph Junghans <junghans@votca.org>
# Date 1326307444 25200
# Branch stable
# Node ID 475999c2cd0d19f739e83c88b2df823c32730bc1
# Parent  7e8f291a6d79da1ebbc512c370b8620714be0cb6
cmake: make it DSO conform

diff -r 7e8f291a6d79 -r 475999c2cd0d CMakeLists.txt
--- a/CMakeLists.txt	Tue Jan 10 20:16:55 2012 -0700
+++ b/CMakeLists.txt	Wed Jan 11 11:44:04 2012 -0700
@@ -4,9 +4,42 @@
 
 project(csgapps)
 
-file(GLOB_RECURSE DIRS */CMakeLists.txt)
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules)
+
+if(NOT CMAKE_BUILD_TYPE)
+  #Release comes with -O3 by default
+  set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
+endif(NOT CMAKE_BUILD_TYPE)
+
+enable_language(CXX)
+include(CheckCXXCompilerFlag)
+
+option(EXTERNAL_BOOST "Use external boost" ON)
+if (EXTERNAL_BOOST)
+  find_package(Boost 1.39.0 COMPONENTS program_options )
+  if(NOT Boost_FOUND)
+    message(FATAL_ERROR "Boost not found,  make sure you have also installed boost and it's dev package or use our internal replacement, if you have built tools with -DEXTERNAL_BOOST=OFF and set it here as well")
+  endif(NOT Boost_FOUND)
+  include_directories(${Boost_INCLUDE_DIRS})
+  set (BOOST_LIBRARIES ${Boost_PROGRAM_OPTIONS_LIBRARY})
+else(EXTERNAL_BOOST)
+  find_package(VOTCA_BOOST REQUIRED)
+  include_directories(${VOTCA_BOOST_INCLUDE_DIRS})
+  set (BOOST_LIBRARIES ${VOTCA_BOOST_LIBRARIES})
+endif(EXTERNAL_BOOST)
+
+find_package(VOTCA_TOOLS REQUIRED)
+include_directories(${VOTCA_TOOLS_INCLUDE_DIRS})
+find_package(VOTCA_CSG REQUIRED)
+include_directories(${VOTCA_CSG_INCLUDE_DIRS})
+
+file(GLOB_RECURSE DIRS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} */CMakeLists.txt)
 foreach(DIR ${DIRS})
-  string(REGEX MATCH ^.*/ DIR ${DIR})
-  add_subdirectory(${DIR})
-  unset(NAME CACHE)
+  string(REGEX MATCH ^[^/]* DIR ${DIR})
+  file(GLOB SRC ${DIR}/*.cc)
+  add_executable(${DIR} ${SRC})
+  target_link_libraries(${DIR} ${VOTCA_CSG_LIBRARIES} ${VOTCA_TOOLS_LIBRARIES} ${BOOST_LIBRARIES})
+  install(TARGETS ${DIR} RUNTIME DESTINATION bin)
+  file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${DIR})
+  set_target_properties(${DIR} PROPERTIES OUTPUT_NAME ${DIR}/csg_${DIR})
 endforeach(DIR)
diff -r 7e8f291a6d79 -r 475999c2cd0d CMakeModules/FindSQLITE3.cmake
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CMakeModules/FindSQLITE3.cmake	Wed Jan 11 11:44:04 2012 -0700
@@ -0,0 +1,36 @@
+# - Find libgmx
+# Find the native libgmx headers and libraries.
+#
+#  SQLITE3_INCLUDE_DIRS - where to find sqlite3.h, etc
+#  SQLITE3_LIBRARIES    - List of libraries when using sqlite3.
+#  SQLITE3_FOUND        - True if sqlite3 found.
+#
+# Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org)
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+find_package(PkgConfig)
+
+pkg_check_modules(PC_SQLITE3 sqlite3)
+
+find_path(SQLITE3_INCLUDE_DIR sqlite3.h HINTS ${PC_SQLITE3_INCLUDE_DIRS})
+find_library(SQLITE3_LIBRARY NAMES sqlite3 HINTS ${PC_SQLITE3_LIBRARY_DIRS} )
+
+set(SQLITE3_LIBRARIES "${SQLITE3_LIBRARY}" )
+set(SQLITE3_INCLUDE_DIRS "${SQLITE3_INCLUDE_DIR}" )
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(SQLITE3 DEFAULT_MSG SQLITE3_LIBRARY SQLITE3_INCLUDE_DIR )
+
+mark_as_advanced(SQLITE3_INCLUDE_DIR SQLITE3_LIBRARY )
diff -r 7e8f291a6d79 -r 475999c2cd0d CMakeModules/FindVOTCA_BOOST.cmake
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CMakeModules/FindVOTCA_BOOST.cmake	Wed Jan 11 11:44:04 2012 -0700
@@ -0,0 +1,37 @@
+# - Find libvotca_boost
+# Find the native libvotca_boost headers and libraries.
+#
+#  VOTCA_BOOST_INCLUDE_DIRS - where to find headers etc.
+#  VOTCA_BOOST_LIBRARIES    - List of libraries when using expat.
+#  VOTCA_BOOST_FOUND        - True if expat found.
+#
+# Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org)
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+find_package(PkgConfig)
+
+pkg_check_modules(PC_VOTCA_BOOST libvotca_boost)
+find_path(VOTCA_BOOST_INCLUDE_DIR boost/algorithm/string/trim.hpp HINTS ${PC_VOTCA_BOOST_INCLUDE_DIRS} )
+find_library(VOTCA_BOOST_LIBRARY NAMES votca_boost HINTS ${PC_VOTCA_BOOST_LIBRARY_DIRS} )
+
+set(VOTCA_BOOST_LIBRARIES "${VOTCA_BOOST_LIBRARY}" )
+set(VOTCA_BOOST_INCLUDE_DIRS "${VOTCA_BOOST_INCLUDE_DIR}" )
+
+include(FindPackageHandleStandardArgs)
+# handle the QUIETLY and REQUIRED arguments and set VOTCA_BOOST_FOUND to TRUE
+# if all listed variables are TRUE
+find_package_handle_standard_args(VOTCA_BOOST DEFAULT_MSG VOTCA_BOOST_LIBRARY VOTCA_BOOST_INCLUDE_DIR)
+
+mark_as_advanced(VOTCA_BOOST_INCLUDE_DIR VOTCA_BOOST_LIBRARY )
diff -r 7e8f291a6d79 -r 475999c2cd0d CMakeModules/FindVOTCA_CSG.cmake
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CMakeModules/FindVOTCA_CSG.cmake	Wed Jan 11 11:44:04 2012 -0700
@@ -0,0 +1,51 @@
+# - Find libvotca_csg
+# Find the native libvotca_csg headers and libraries.
+#
+#  VOTCA_CSG_INCLUDE_DIRS - where to find votca/csg/version.h, etc.
+#  VOTCA_CSG_LIBRARIES    - List of libraries when using expat.
+#  VOTCA_CSG_FOUND        - True if expat found.
+#  VOTCA_CSG_HAS_SQLITE3  - True if votca csg was build with sqlite3 support
+#
+# Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org)
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+find_package(PkgConfig)
+
+pkg_check_modules(PC_VOTCA_CSG libvotca_csg)
+find_path(VOTCA_CSG_INCLUDE_DIR votca/csg/version.h HINTS ${PC_VOTCA_CSG_INCLUDE_DIRS})
+
+find_library(VOTCA_CSG_LIBRARY NAMES votca_csg HINTS ${PC_VOTCA_CSG_LIBRARY_DIRS} )
+
+if("${VOTCA_CSG_LIBRARY}" MATCHES "libvotca_csg[^;]*\\.a")
+    if(PC_VOTCA_CSG_LIBRARIES)
+      list(REMOVE_ITEM PC_VOTCA_CSG_LIBRARIES votca_csg)
+      foreach (LIB ${PC_VOTCA_CSG_LIBRARIES})
+        find_library(VOTCA_CSG_${LIB} NAMES ${LIB} HINTS ${PC_VOTCA_CSG_LIBRARY_DIRS} )
+        list(APPEND VT_DEP_LIBRARIES ${VOTCA_CSG_${LIB}})
+        unset(VOTCA_CSG_${LIB} CACHE)
+      endforeach(LIB)
+    endif(PC_VOTCA_CSG_LIBRARIES)
+    set(VOTCA_CSG_DEP_LIBRARIES "${VT_DEP_LIBRARIES}" CACHE FILEPATH "votca csg depency libs (only needed for static (.a) libvotca_csg")
+endif("${VOTCA_CSG_LIBRARY}" MATCHES "libvotca_csg[^;]*\\.a")
+
+set(VOTCA_CSG_LIBRARIES "${VOTCA_CSG_LIBRARY};${VOTCA_CSG_DEP_LIBRARIES}" )
+set(VOTCA_CSG_INCLUDE_DIRS "${VOTCA_CSG_INCLUDE_DIR}" )
+
+include(FindPackageHandleStandardArgs)
+# handle the QUIETLY and REQUIRED arguments and set VOTCA_CSG_FOUND to TRUE
+# if all listed variables are TRUE
+find_package_handle_standard_args(VOTCA_CSG DEFAULT_MSG VOTCA_CSG_LIBRARY VOTCA_CSG_INCLUDE_DIR )
+
+mark_as_advanced(VOTCA_CSG_INCLUDE_DIR VOTCA_CSG_LIBRARY )
diff -r 7e8f291a6d79 -r 475999c2cd0d CMakeModules/FindVOTCA_TOOLS.cmake
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CMakeModules/FindVOTCA_TOOLS.cmake	Wed Jan 11 11:44:04 2012 -0700
@@ -0,0 +1,68 @@
+# - Find libvotca_tools
+# Find the native libvotca_tools headers and libraries.
+#
+#  VOTCA_TOOLS_INCLUDE_DIRS - where to find votca/tools/version.h, etc.
+#  VOTCA_TOOLS_LIBRARIES    - List of libraries when using expat.
+#  VOTCA_TOOLS_FOUND        - True if expat found.
+#  VOTCA_TOOLS_HAS_SQLITE3  - True if votca tools was build with sqlite3 support
+#
+# Copyright 2009-2011 The VOTCA Development Team (http://www.votca.org)
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+find_package(PkgConfig)
+
+pkg_check_modules(PC_VOTCA_TOOLS libvotca_tools)
+find_path(VOTCA_TOOLS_INCLUDE_DIR votca/tools/version.h HINTS ${PC_VOTCA_TOOLS_INCLUDE_DIRS})
+
+find_path(VOTCA_TOOLS_HAS_SQLITE3 votca/tools/database.h HINTS ${PC_VOTCA_TOOLS_INCLUDE_DIRS})
+if (VOTCA_TOOLS_HAS_SQLITE3)
+  #due to include <sqlite3.h> in database.h
+  find_package(SQLITE3 REQUIRED)
+  set(VOTCA_TOOLS_INCLUDE_DIRS "${VOTCA_TOOLS_INCLUDE_DIR};${SQLITE3_INCLUDE_DIR}" )
+else(VOTCA_TOOLS_HAS_SQLITE3)
+  set(VOTCA_TOOLS_INCLUDE_DIRS "${VOTCA_TOOLS_INCLUDE_DIR}" )
+endif (VOTCA_TOOLS_HAS_SQLITE3)
+
+
+find_library(VOTCA_TOOLS_LIBRARY NAMES votca_tools HINTS ${PC_VOTCA_TOOLS_LIBRARY_DIRS} )
+
+if("${VOTCA_TOOLS_LIBRARY}" MATCHES "libvotca_tools[^;]*\\.a")
+    if(PC_VOTCA_TOOLS_LIBRARIES)
+      list(REMOVE_ITEM PC_VOTCA_TOOLS_LIBRARIES votca_tools)
+      foreach (LIB ${PC_VOTCA_TOOLS_LIBRARIES})
+        find_library(VOTCA_TOOLS_${LIB} NAMES ${LIB} HINTS ${PC_VOTCA_TOOLS_LIBRARY_DIRS} )
+        list(APPEND VT_DEP_LIBRARIES ${VOTCA_TOOLS_${LIB}})
+        unset(VOTCA_TOOLS_${LIB} CACHE)
+      endforeach(LIB)
+    endif(PC_VOTCA_TOOLS_LIBRARIES)
+    set(VOTCA_TOOLS_DEP_LIBRARIES "${VT_DEP_LIBRARIES}" CACHE FILEPATH "votca tools depency libs (only needed for static (.a) libvotca_tools")
+endif("${VOTCA_TOOLS_LIBRARY}" MATCHES "libvotca_tools[^;]*\\.a")
+
+set(VOTCA_TOOLS_LIBRARIES "${VOTCA_TOOLS_LIBRARY};${VOTCA_TOOLS_DEP_LIBRARIES}" )
+
+include(FindPackageHandleStandardArgs)
+# handle the QUIETLY and REQUIRED arguments and set VOTCA_TOOLS_FOUND to TRUE
+# if all listed variables are TRUE
+find_package_handle_standard_args(VOTCA_TOOLS DEFAULT_MSG VOTCA_TOOLS_LIBRARY VOTCA_TOOLS_INCLUDE_DIR )
+
+if (VOTCA_TOOLS_FOUND)
+  include(CheckLibraryExists)
+  check_library_exists("${VOTCA_TOOLS_LIBRARY};${VOTCA_TOOLS_DEP_LIBRARIES}" VotcaToolsFromC "" FOUND_VOTCA_TOOLS_VERSION)
+  if(NOT FOUND_VOTCA_TOOLS_VERSION)
+    message(FATAL_ERROR "Could not find VotcaToolsFromC in ${VOTCA_TOOLS_LIBRARY};${VOTCA_TOOLS_DEP_LIBRARIES}, take look at the error message in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log to find out what was going wrong. If you don't have pkg-config installed you will most likely have to set VOTCA_TOOLS_LIBRARY and VOTCA_TOOLS_DEP_LIBRARIES by hand, which set votca_tools lib  it's depencies (i.e. -DVOTCA_TOOLS_LIBRARY='/path/to/libvotca_tools.so" -VOTCA_TOOLS_DEP_LIBRARIES="/path/to/libgsl.so;/path/to/libm.so') !")
+  endif(NOT FOUND_VOTCA_TOOLS_VERSION)
+endif (VOTCA_TOOLS_FOUND)
+
+mark_as_advanced(VOTCA_TOOLS_INCLUDE_DIR VOTCA_TOOLS_LIBRARY )