forked from DrStS/EMPIRE-Libraries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
127 lines (121 loc) · 6.33 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
#------------------------------------------------------------------------------------#
IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
ExternalProject_Add(flann
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/flann-1.7.1-src
BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/flann-1.7.1-src/build
INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib
CONFIGURE_COMMAND cmake -D BUILD_C_BINDINGS=OFF -D CMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_SOURCE_DIR}/lib ..
BUILD_COMMAND $(MAKE)
INSTALL_COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/flann-1.7.1-src/build/lib/libflann_cpp_s.a ${CMAKE_CURRENT_SOURCE_DIR}/lib/libflann_cpp_s.a
)
ExternalProject_Add(nlopt
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/nlopt-2.4.1
BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/nlopt-2.4.1/build
INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib
CONFIGURE_COMMAND cmake -D BUILD_C_BINDINGS=ON -D CMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_SOURCE_DIR}/lib ..
BUILD_COMMAND $(MAKE)
INSTALL_COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/nlopt-2.4.1/build/libnlopt.a ${CMAKE_CURRENT_SOURCE_DIR}/lib/libnlopt.a
)
ExternalProject_Add(clipper
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/clipper_ver6.1.3a/cpp
BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/clipper_ver6.1.3a/build
INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib
CONFIGURE_COMMAND cmake -D BUILD_C_BINDINGS=OFF -D CMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_SOURCE_DIR}/lib ../cpp
BUILD_COMMAND $(MAKE)
INSTALL_COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/clipper_ver6.1.3a/build/libpolyclipping.a ${CMAKE_CURRENT_SOURCE_DIR}/lib
)
ExternalProject_Add(eigen
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Eigen
INSTALL_COMMAND make
)
# ExternalProject_Add(nlopt
# SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/nlopt-2.4.1
# BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/nlopt-2.4.1/build
# INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/nlopt-2.4.1/lib
# CONFIGURE_COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/nlopt-2.4.1/configure --prefix=${CMAKE_CURRENT_SOURCE_DIR}/nlopt-2.4.1
# BUILD_COMMAND make
# INSTALL_COMMAND make install
# )
ENDIF()
SET(ENV{TEST} ${CMAKE_CURRENT_SOURCE_DIR})
IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
ExternalProject_Add(flann
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/flann-1.7.1-src
BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/flann-1.7.1-src/build
INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib
CONFIGURE_COMMAND cmake -G "NMake Makefiles" -D BUILD_C_BINDINGS=OFF -D CMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_SOURCE_DIR}/lib ..
BUILD_COMMAND nmake
INSTALL_COMMAND cd ${CMAKE_CURRENT_SOURCE_DIR}/flann-1.7.1-src/build/lib/ && copy flann_cpp_s.lib ..\\..\\..\\lib
)
# TODO DEBUG ? COMPILATION FOR WINDOWS OF NLOPT
ExternalProject_Add(nlopt
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/nlopt-2.4.1
BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/nlopt-2.4.1/build
INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib
CONFIGURE_COMMAND cmake -G "NMake Makefiles" -D BUILD_C_BINDINGS=OFF -D CMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_SOURCE_DIR}/lib ..
BUILD_COMMAND $(MAKE)
INSTALL_COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/nlopt-2.4.1/build/ ${CMAKE_CURRENT_SOURCE_DIR}/lib/libnlopt.a && copy nlopt.lib ..\\..\\lib
)
ENDIF()
#------------------------------------------------------------------------------------#
FILE(GLOB EMPIRE_API_SOURCES_src_subdirectories "*")
FOREACH(f ${EMPIRE_API_SOURCES_src_subdirectories})
IF(NOT f MATCHES "\\.txt" AND IS_DIRECTORY ${f} )
# add_subdirectory(${f})
ENDIF()
ENDFOREACH()
add_subdirectory(ticpp) # TODO
add_subdirectory(cppunit)
add_subdirectory(dataCreator)
add_subdirectory(Eigen)
#------------------------------------------------------------------------------------#
IF (${USE_INTEL_COMPILERS_MKL_IMPI_LINUX})
SET (CMAKE_C_COMPILER "icc")
SET (CMAKE_CXX_COMPILER "icpc")
ENDIF()
IF (${USE_GNU_COMPILERS_EINGEN_LINUX})
SET (CMAKE_C_COMPILER "gcc")
SET (CMAKE_CXX_COMPILER "g++")
ENDIF()
#------------------------------------------------------------------------------------#
ExternalProject_Get_Property(flann SOURCE_DIR)
MACRO_APPEND_GLOBAL_VARIABLE(EMPIRE_thirdparty_INCLUDES "${SOURCE_DIR}/src/cpp")
ExternalProject_Get_Property(nlopt SOURCE_DIR)
MACRO_APPEND_GLOBAL_VARIABLE(EMPIRE_thirdparty_INCLUDES "${SOURCE_DIR}/api")
ExternalProject_Get_Property(clipper SOURCE_DIR)
MACRO_APPEND_GLOBAL_VARIABLE(EMPIRE_thirdparty_INCLUDES "${SOURCE_DIR}")
ExternalProject_Get_Property(eigen SOURCE_DIR)
MACRO_APPEND_GLOBAL_VARIABLE(EMPIRE_thirdparty_INCLUDES "${SOURCE_DIR}")
# MACRO_APPEND_GLOBAL_VARIABLE(EMPIRE_thirdparty_INCLUDES "${SOURCE_DIR}/include")
#------------------------------------------------------------------------------------#
get_property(EMPIRE_thirdparty_INCLUDES GLOBAL PROPERTY EMPIRE_thirdparty_INCLUDES)
get_property(EMPIRE_thirdparty_SOURCES GLOBAL PROPERTY EMPIRE_thirdparty_SOURCES)
#------------------------------------------------------------------------------------#
include_directories(${EMPIRE_thirdparty_INCLUDES})
#------------------------------------------------------------------------------------#
# Compiler flags & defines EMPIRE_thirdparty
add_definitions(-DTIXML_USE_TICPP)
add_definitions(-DNDEBUG)
#------------------------------------------------------------------------------------#
# Needed because Cmake does add it automatically only for shared libraries
# Cmake considers static libs as archives and not as a library
IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
SET (CMAKE_C_FLAGS "-fPIC")
SET (CMAKE_CXX_FLAGS "-fPIC")
ENDIF()
IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /EHsc")
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc")
ENDIF()
#------------------------------------------------------------------------------------#
add_library(EMPIRE_thirdparty OBJECT ${EMPIRE_thirdparty_SOURCES})
#------------------------------------------------------------------------------------#
# Add dependencies to targets
add_dependencies(EMPIRE_thirdparty flann)
add_dependencies(EMPIRE_thirdparty nlopt)
add_dependencies(EMPIRE_thirdparty clipper)
add_dependencies(EMPIRE_thirdparty eigen)
#------------------------------------------------------------------------------------#
#MESSAGE("C Compiler Flags for EMPIRE_thirdparty are:\t${CMAKE_C_FLAGS} \nC++ Compiler Flags for EMPIRE_thirdparty are:\t${CMAKE_CXX_FLAGS}")
#MESSAGE("EMPIRE_thirdparty_INCLUDES: ${EMPIRE_thirdparty_INCLUDES}")
#MESSAGE("EMPIRE_thirdparty_SOURCES: ${EMPIRE_thirdparty_SOURCES}")