-
Notifications
You must be signed in to change notification settings - Fork 12
/
CMakeLists.txt
418 lines (317 loc) · 13.8 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
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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
CMAKE_MINIMUM_REQUIRED(VERSION 3.3)
PROJECT(OApackage)
# ----------------------------------------------------------------------------
# External packages
# ----------------------------------------------------------------------------
if(WIN32)
set(CMAKE_CONFIGURATION_TYPES "Release" CACHE TYPE INTERNAL FORCE) # no Debug
else()
find_package(Boost QUIET COMPONENTS system filesystem )
message(STATUS "Boost_LIBRARIES: ${Boost_LIBRARIES}")
if (Boost_FOUND)
message(STATUS "Boost was found")
endif()
endif()
find_package(ZLIB) # Needed for Python modules
if(ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIRS})
endif()
message(STATUS "ZLIB_FOUND: ${ZLIB_FOUND}")
if(ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIRS})
endif()
find_package(SWIG) # Needed for Python modules
find_package(NumPy QUIET) # Needed for Python modules
if (NumPy_FOUND)
message(STATUS "NumPy was found")
endif()
# ----------------------------------------------------------------------------
# Code
# ----------------------------------------------------------------------------
set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_EXTENSIONS OFF)
include_directories(.)
include_directories(src)
include_directories(nauty)
link_directories(${CMAKE_SOURCE_DIR})
set(OADEV 0)
message(STATUS "OA development mode: ${OADEV}")
set(headers src/pareto.h src/unittests.h src/anyoption.h src/arrayproperties.h src/arraytools.h src/graphtools.h src/mathtools.h src/oaoptions.h src/tools.h src/md5.h src/Deff.h src/evenodd.h src/version.h)
set(srcs src/pareto.cpp src/unittests.cpp src/anyoption.cpp src/md5.cpp src/strength.cpp src/arrayproperties.cpp src/graphtools.cpp src/arraytools.cpp src/mathtools.cpp src/tools.cpp src/oaoptions.cpp src/bitarray/bit_array.cpp src/Deff.cpp src/evenodd.cpp)
set(headers ${headers} src/conference.h)
set(srcs ${srcs} src/conference.cpp)
set(headersextend ${headers} src/extend.h src/strength.h src/lmc.h src/nonroot.h )
set(srcsextend ${srcs} src/extend.cpp src/lmc.cpp src/nonroot.cpp )
set(headersextend ${headersextend} src/InfInt.h)
set(srcsextend ${srcsextend} src/InfInt.cpp)
set(headersextend ${headersextend} src/depth_extend.h)
set(srcsextend ${srcsextend} src/depth_extend.cpp)
include_directories(dev)
set(OUTPUTDIR ${CMAKE_SOURCE_DIR})
if(OADEV)
# if development code, try to use openmp
find_package(OpenMP )
if(OPENMP_FOUND AND OADEV)
message(STATUS "OpenMP found: OpenMP_C_FLAGS ${OpenMP_C_FLAGS}, OpenMP_EXE_LINKER_FLAGS ${OpenMP_EXE_LINKER_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS} -DDOOPENMP")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} -DDOOPENMP")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
else()
message(STATUS "OpenMP not found! building code without OpenMP support")
endif()
endif(OADEV)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(STATUS "Using CLang compiler")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++11-compat-deprecated-writable-strings -fPIC")
if(NOCOMPILERWARNINGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
endif()
endif()
# used for HPC at Antwerpen
#option(INTEL_CC "Use the Intel compiler." OFF)
site_name(HOSTNAME)
string(FIND ${HOSTNAME} hopper VSC)
if(VSC GREATER 0)
set(VSC TRUE)
else()
set(VSC FALSE)
endif()
message(STATUS "Hostname ${HOSTNAME}, VSC ${VSC}")
if (VSC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
endif()
if (INTEL_CC)
find_program(CMAKE_C_COMPILER NAMES icc)
find_program(CMAKE_CXX_COMPILER NAMES icpc)
find_program(CMAKE_AR NAMES xiar)
find_program(CMAKE_LINKER NAMES xild)
if (CMAKE_C_COMPILER MATCHES CMAKE_C_COMPILER-NOTFOUND OR
CMAKE_CXX_COMPILER MATCHES CMAKE_CXX_COMPILER-NOTFOUND OR
CMAKE_AR MATCHES CMAKE_AR-NOTFOUND OR
CMAKE_LINKER MATCHES CMAKE_LINKER-NOTFOUND)
message(FATAL_ERROR "Cannot find Intel compiler. You may need to run `. /opt/intel/bin/compilervars.sh intel64'")
endif ()
message(STATUS "At HPC cluster")
endif (INTEL_CC)
set(LINKOPTS "")
if( "$ENV{USER}" STREQUAL "vsc20149")
set(LINKOPTS "-s") # strip executables for file size
endif()
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wno-alloc-size-larger-than -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-result -Wno-unknown-pragmas -fPIC -g") # -fpermissive #
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g")
set(COPTS "${COPTS} -O3 ")
set(COPTS "${COPTS} -DEIGEN_MPL2_ONLY")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-write-strings") # remove warnings
if(NOCOMPILERWARNINGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
else()
set(COPTS "${COPTS} -pedantic -Wno-variadic-macros") # make code comply to R
endif()
endif ()
if("$ENV{OADEBUG}" STREQUAL "1")
set(COPTS "-g -O0 -DOADEBUG" ) # -std=c++0x -Weffc++")
endif()
if(WIN32)
set(COPTS "/MT /wd4018 /wd4996")
endif()
if (MSVC)
message(STATUS "MSCV compiler")
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc /W0 /wd4996 /wd4244 /wd26451 /wd26495 /wd6255 /D_SCL_SECURE_NO_WARNINGS")
set ( CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
endif()
set(COPTS "${COPTS} -DFULLPACKAGE")
if(ZLIB_FOUND)
set(COPTS "${COPTS} -DUSEZLIB")
include_directories(ZLIB_INCLUDE_DIRS)
else()
set(COPTS "${COPTS} -DNOZLIB")
endif()
if (VERBOSE)
message(STATUS "copts ${COPTS}")
endif()
if(Boost_FOUND)
INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )
set(COPTS "${COPTS} -DHAVE_BOOST")
endif()
set(COPTS "${COPTS} -DOADEV")
macro(add_compile_flags _target)
# Provide user feedback
set_target_properties(${_target} PROPERTIES COMPILE_DEFINITIONS "OAEXTEND_SINGLECORE;NEWINTERFACE " )
set_target_properties(${_target} PROPERTIES COMPILE_FLAGS "${COPTS}" )
set_target_properties(${_target} PROPERTIES LINK_FLAGS "${LINKOPTS}")
endmacro()
############### Programs ################################
include_directories(.)
set(nautysrc src/nauty/nauty.c src/nauty/nautinv.c src/nauty/nautil.c src/nauty/naurng.c src/nauty/naugraph.c src/nauty/schreier.c src/nauty/naugroup.c) # nauty/gtools.c
include_directories(src/nauty)
set(graphsrc )
set(progs oacat oajoin oapareto oasplit oaanalyse oainfo oaunittest oaconvert oafilter oareduceDOP pareto_example oaconference oaconfcheck)
set(progsextend )
list(APPEND progs oacheck oastreaming oaranktest oatest oaclustergather)
list(APPEND progs oa_depth_extend oa_select_maxj)
if (WIN32)
add_library(oalib STATIC ${srcsextend} ${headersextend} ${nautysrc} ${graphsrc})
add_compile_flags(oalib)
add_library(oalibshared SHARED ${srcsextend} ${headersextend} ${nautysrc} ${graphsrc})
add_compile_flags(oalibshared)
if(ZLIB_FOUND)
TARGET_LINK_LIBRARIES(oalib ${ZLIB_LIBRARIES})
TARGET_LINK_LIBRARIES(oalibshared ${ZLIB_LIBRARIES})
endif()
else()
add_library(oalib STATIC ${srcsextend} ${headersextend} ${nautysrc} ${graphsrc})
add_compile_flags(oalib)
add_library(oalibshared SHARED ${srcsextend} ${headersextend} ${nautysrc} ${graphsrc})
add_compile_flags(oalib)
TARGET_LINK_LIBRARIES(oalib m)
TARGET_LINK_LIBRARIES(oalibshared m)
if(ZLIB_FOUND)
TARGET_LINK_LIBRARIES(oalib ${ZLIB_LIBRARIES})
TARGET_LINK_LIBRARIES(oalibshared ${ZLIB_LIBRARIES})
endif()
endif()
add_executable(oaextendsingle "utils/oaextend.cpp" ${headersextend})
add_compile_flags(oaextendsingle)
TARGET_LINK_LIBRARIES(oaextendsingle oalib)
set(extendprogs oaextendsingle )
message(STATUS "Extend progs: ${extendprogs}")
message(STATUS "Progs: ${progs}")
###############
foreach(item ${progs})
ADD_EXECUTABLE(${item} "utils/${item}.cpp" ${headers} ) # ${srcs}
add_compile_flags(${item})
TARGET_LINK_LIBRARIES(${item} oalib)
if (WIN32)
if(ZLIB_FOUND)
TARGET_LINK_LIBRARIES(${item} ${ZLIB_LIBRARIES})
endif()
else()
TARGET_LINK_LIBRARIES(${item} m)
endif()
if(ZLIB_FOUND)
TARGET_LINK_LIBRARIES(${item} ${ZLIB_LIBRARIES})
endif()
endforeach()
foreach(item ${extendprogs})
if (WIN32)
else()
set_target_properties(${item} PROPERTIES COMPILE_FLAGS "${COPTS}" )
TARGET_LINK_LIBRARIES(${item} m)
endif()
if(ZLIB_FOUND)
TARGET_LINK_LIBRARIES(${item} ${ZLIB_LIBRARIES})
endif()
set_target_properties(${item} PROPERTIES LINK_FLAGS "${LINKOPTS}" )
endforeach()
if(Boost_FOUND)
foreach(item ${progs} ${extendprogs})
target_link_libraries(${item} ${Boost_LIBRARIES})
endforeach()
endif()
site_name(HOSTNAME)
#message(STATUS "Hostname ${HOSTNAME}")
####### Octave / Matlab support ##########################
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR})
find_package(Matlab)
message(STATUS "Matlab: ${MATLAB_FOUND}, Matlab_LIBRARIES ${Matlab_LIBRARIES}")
set(MATLAB_FOUND ${Matlab_FOUND})
set(MATLAB_LIBRARIES ${Matlab_LIBRARIES})
if(MATLAB_FOUND)
message(STATUS ${srcs})
set(Ditems Doptim)
ADD_LIBRARY(Doptim EXCLUDE_FROM_ALL SHARED mex/Doptim.cpp)
set_target_properties(${item} PROPERTIES COMPILE_FLAGS "-DMATLAB_MEX_FILE ${COPTS} ")
ADD_EXECUTABLE(Doptimbin EXCLUDE_FROM_ALL mex/Doptim.cpp) # ${srcs} ${srcsextend})
set_target_properties(${item} PROPERTIES COMPILE_FLAGS "-DMATLAB_MEX_FILE ${COPTS} -DMAINMEX")
list(APPEND Ditems Doptimbin)
message(STATUS "libs ${MATLAB_LIBRARIES}")
foreach(item ${Ditems})
message(STATUS "adding ${item}")
if(WIN32)
TARGET_LINK_LIBRARIES(${item} m ${ZLIB_LIBRARIES} )
endif()
TARGET_LINK_LIBRARIES(${item} ${MATLAB_LIBRARIES})
TARGET_LINK_LIBRARIES(${item} oalib)
GET_TARGET_PROPERTY(itemtype ${item} TYPE)
if(WIN32)
set(MEXEXTX ".mexw${BITNESS}")
if (${itemtype} MATCHES "EXECUTABLE")
SET_TARGET_PROPERTIES(${item} PROPERTIES SUFFIX "")
else()
if (CYGWIN)
SET_TARGET_PROPERTIES(${item} PROPERTIES SUFFIX ${MEXEXTX})
else()
SET_TARGET_PROPERTIES(${item} PROPERTIES SUFFIX ${MEXEXTX} LINK_FLAGS /export:mexFunction)
endif()
endif()
endif(WIN32)
if (${itemtype} MATCHES "EXECUTABLE")
SET_TARGET_PROPERTIES(${item} PROPERTIES SUFFIX "")
else()
if(WIN32)
SET_TARGET_PROPERTIES(${item} PROPERTIES SUFFIX ".mexw${BITNESS}")
else()
SET_TARGET_PROPERTIES(${item} PROPERTIES SUFFIX ".mexa${BITNESS}")
endif()
endif()
set_target_properties(${item} PROPERTIES PREFIX "")
endforeach()
endif()
add_custom_target( doc )
add_custom_command(
TARGET doc
POST_BUILD
COMMAND doxygen Doxyfile
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
################ INSTALLATION OPTIONS ###########################
foreach(prog ${progs})
install (TARGETS ${prog} DESTINATION bin)
endforeach()
foreach(prog ${extendprogs})
install (TARGETS ${prog} DESTINATION bin)
endforeach()
install (TARGETS oalib DESTINATION lib)
install (FILES README.md LICENSE DESTINATION doc)
install (FILES oaconfig.txt DESTINATION bin)
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Program to calculate orthogonal arrays")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
SET(CPACK_PACKAGE_VERSION_MAJOR "2")
SET(CPACK_PACKAGE_VERSION_MINOR "4")
SET(CPACK_PACKAGE_VERSION_PATCH "15")
set(CPACK_SOURCE_GENERATOR TGZ)
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-source")
set(CPACK_SOURCE_IGNORE_FILES "tests.txt$;/vsc/;/old/;/Eigen3.2/;/Eigen-devel/;/Eigen3.1/;/buildvs/;a.out$;/TestingCommands;/testing/;tags$;_oalib.so$;Makefile$;setup.py~$;ChangeLog~$;CMakeFiles$;TODO$;oaconfig-speedtest.txt$;CMakeCache.txt;cmake_install.cmake;.pyc$;/oacode.kdev4;/OA.kde;.cpp~$;/CMakeLists-develop.txt;/build/;/matlabtools/;/xml/;/pythonscripts/;/miscx/;/performancetest/;/oldx/;/buildwin/;/html/;/testsuite/;/.svn/;${CPACK_SOURCE_IGNORE_FILES}")
set(CPACK_SOURCE_IGNORE_FILES "example.so;PrecompiledHeader.cmake;/Eigen3.2.1/" ${CPACK_SOURCE_IGNORE_FILES})
set(CPACK_SOURCE_IGNORE_FILES "mex/Doptim.mex;/.git/;/appveyor/;/tmp/;/dist/;/build2/;/hopper/;/OAlib.egg-info/;/buildx/;/OApackage.egg-info/;x2.txt;appveyor.yml;oalib_wrap_dev.cxx;oalib_wrap.cpp;oalib_wrap.cxx;sandbox;" ${CPACK_SOURCE_IGNORE_FILES})
set(CPACK_SOURCE_IGNORE_FILES "\\\\.cpp~$" "\\\\.txt~$" ${CPACK_SOURCE_IGNORE_FILES})
set(CPACK_SOURCE_IGNORE_FILES "~$" ${CPACK_SOURCE_IGNORE_FILES})
if (VERBOSE)
message(STATUS "CPACK_SOURCE_IGNORE_FILES ${CPACK_SOURCE_IGNORE_FILES}")
endif()
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-extend-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-source")
set(CPACK_SOURCE_IGNORE_FILES "/testdata/;/pythondevelop/;${CPACK_SOURCE_IGNORE_FILES}")
set(CPACK_SOURCE_IGNORE_FILES "oaextendA.cpp$;oatest.cpp$;oa_depth_extend.cpp$;{CPACK_SOURCE_IGNORE_FILES}")
#message(STATUS "CPACK_SOURCE_IGNORE_FILES ${CPACK_SOURCE_IGNORE_FILES}")
# cmake package type: CygwinBinary, DEB, TGZ, ZIP, etc.
if(WIN32)
SET(CPACK_GENERATOR "ZIP")
else()
SET(CPACK_GENERATOR "TGZ")
endif()
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Pieter Eendebak")
INCLUDE(CPack)
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
### for VCS
#module load SWIG/2.0.4-ictce-4.0.1-Python-2.7.3
#module load zlib/1.2.5-ictce-4.0.1
#module load CMake/2.8.0-ictce-3.2.1.015.u1 # negeer de ERROR die je krijgt
#export CC=icc
#export CXX=icpc
# cmake -DCMAKE_INSTALL_PREFIX:PATH=~vsc20149 ..
# or
# module load GCC/4.7.0
# cmake -DCMAKE_INSTALL_PREFIX:PATH=~vsc20149 -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ ..
# source formatting: clang-format -style="{BasedOnStyle: llvm, IndentWidth: 8, ColumnLimit: 119, SpaceBeforeParens: Always, SpacesInAngles: true}" -i *.h *.cpp
# also see: http://cf.monofraps.net/