forked from eglrp/ROCKET
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·131 lines (106 loc) · 4.93 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
# Minimum Required CMake Version
cmake_minimum_required(VERSION 2.8.4)
# Project Name
project (rocket)
# System Variables
message ("system = ${CMAKE_SYSTEM}")
message ("system_name = ${CMAKE_SYSTEM_NAME}")
# Installation Path Prefix - Change to desired location
set (CMAKE_INSTALL_PREFIX $ENV{rocket})
if (UNIX) #Unix Compiler Options
set (STADYN "SHARED") #Dynamic Libraries Enabled
if (APPLE) #Apple Compiler Options
set (CMAKE_SHARED_LIBRARY_SUFFIX .dylib)
set (CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -shared")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "SunOS") #Solaris Compiler Options
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -mt")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -compat=5 -erroff=hidevf,wvarhidemem,badargtype2w -lgen -lnsl -lsocket")
else (APPLE)
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -shared")
endif (APPLE)
elseif (WIN32) #Windows Compiler Options
if (MSVC11) #Compiler Options for Microsoft Visual Studio 11 (2012)
set (STADYN "STATIC") #Static Libraries Enabled
add_definitions (/MP /D_SCL_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS /D_USE_MATH_DEFINES /EHsc /GR /wd"4274"
/wd"4503" /wd"4290" /wd"4267" /wd"4250" /wd"4244" /wd"4101" /wd"4800" /wd"4068")
elseif (MSVC10) #Compiler Options for Microsoft Visual Studio 10 (2010)
set (STADYN "STATIC") #Static Libraries Enabled
include_directories("C:/Program\ Files\ (x86)/GnuWin32/include")
link_directories("C:/Program\ Files\ (x86)/GnuWin32/lib")
add_definitions (/MP /D_SCL_SECURE_NO_WARNINGS /D_CRT_SECURE_NO_WARNINGS /D_USE_MATH_DEFINES /EHsc /GR /wd"4274"
/wd"4503" /wd"4290" /wd"4267" /wd"4250" /wd"4244" /wd"4101" /wd"4800" /wd"4068")
endif (MSVC11)
endif(UNIX)
# Use, i.e. don't skip the full RPATH for the build tree
set (CMAKE_SKIP_BUILD_RPATH FALSE)
# When building, don't use the install RPATH
# (but later on when installing)
set (CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}:$ORIGIN/../lib")
# Add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# The RPATH to be used when installing, but only if it's not a system directory
list (FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}:$ORIGIN/../lib" isSystemDir)
if ("${isSystemDir}" STREQUAL "-1")
set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}:$ORIGIN/../lib")
endif ("${isSystemDir}" STREQUAL "-1")
# NEED_GETOPT flag for Sources
if (NOT "${CMAKE_COMPILER_IS_GNUCC}" )
set(NEED_GETOPT TRUE)
endif(NOT "${CMAKE_COMPILER_IS_GNUCC}" )
# Debug script - uncomment for printing of all cmake variables
#get_cmake_property(_variableNames VARIABLES)
#foreach (_variableName ${_variableNames})
# message(STATUS "${_variableName}=${${_variableName}}")
#endforeach()
# Recursively search through lib and group the following file types
file(GLOB_RECURSE SOURCES "lib/*.cpp")
file(GLOB_RECURSE SOURCES2 "lib/*.c")
file(GLOB_RECURSE HEADERS "lib/*.h")
file(GLOB_RECURSE HEADERS2 "lib/*.hpp")
# ap out the directory structure of lib for includes
set (INCLUDE_DIRS "")
foreach (_headerFile ${HEADERS})
get_filename_component(_dir ${_headerFile} PATH)
list (APPEND INCLUDE_DIRS ${_dir})
endforeach()
foreach (_headerFile ${HEADERS2})
get_filename_component(_dir ${_headerFile} PATH)
list (APPEND INCLUDE_DIRS ${_dir})
endforeach()
list(REMOVE_DUPLICATES INCLUDE_DIRS)
# Include the mapped lib directory structure
include_directories(${INCLUDE_DIRS})
# Create the rocket library
add_library (rocket ${STADYN} ${SOURCES} ${SOURCES2})
# Install the rocket library and headers
install (TARGETS rocket DESTINATION lib)
install (FILES ${HEADERS} ${HEADERS2} DESTINATION include/rocket )
## Parallel Options
option(USE_OPENMP "Use openmp" ON)
message("openmp=${USE_OPENMP}")
if (USE_OPENMP)
# add macros
add_definitions(-DUSE_OPENMP)
if (APPLE)
set (CMAKE_CXX_COMPILER clang-omp)
include_directories("/usr/local/include")
include_directories("/usr/local/include/libiomp")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lstdc++")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++")
target_link_libraries(rocket "/usr/local/lib/libiomp5.dylib")
elseif ( ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lstdc++" )
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++")
else (APPLE)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lstdc++" )
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++")
endif (APPLE)
endif(USE_OPENMP)
# ROCKET Subdirectories
add_subdirectory (tests)