forked from je-santos/MPLBM-UT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
116 lines (91 loc) · 3.66 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
if(CI)
###############################################################################
get_filename_component(EXECUTABLE_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
###############################################################################
get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
add_executable(${PROJECT_NAME} "./${EXECUTABLE_NAME}.cpp")
# Link with the following libraries
target_link_libraries(${PROJECT_NAME} palabos-v2.2.1)
if(ENABLE_MPI)
target_link_libraries(${PROJECT_NAME} ${MPI_CXX_LIBRARIES})
endif()
###############################################################################
# This returns when you compile Palabos and all the examples (root CMakeLists.txt)
return()
###############################################################################
endif()
message("Build example separately")
cmake_minimum_required(VERSION 2.8.12)
project(palabosExample)
enable_language(CXX)
set(EXECUTABLE_NAME "permeability")
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "../")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
#set(CMAKE_CONFIGURATION_TYPES "Debug;Release")
endif()
message("Generated with config types: ${CMAKE_CONFIGURATION_TYPES}")
message(${CMAKE_BUILD_TYPE})
# Compiler flags
# Append flags: set(CMAKE_XXX_FLAGS "${CMAKE_XXX_FLAGS} ...")
if(${CMAKE_CXX_COMPILER_ID} STREQUAL GNU)
message("GCC.")
set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wnon-virtual-dtor")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-g -DPLB_DEBUG -O0")
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL Clang)
message("Clang.")
set(CMAKE_CXX_FLAGS "-std=c++11 -Wall -Wnon-virtual-dtor")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-g -DPLB_DEBUG -O0")
elseif(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC)
message("MSVC.")
set(CMAKE_CXX_FLAGS_RELEASE "/Ox /Ot /GS- /GL /DNDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "/DPLB_DEBUG")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/LTCG /INCREMENTAL:NO /OPT:REF")
else()
message( FATAL_ERROR "CXX compiler not recognized. CMake will quit." )
endif()
option(ENABLE_MPI "Enable MPI" ON)
if(ENABLE_MPI)
message("Enabling MPI")
find_package(MPI REQUIRED)
if(MPI_CXX_FOUND)
#set(CMAKE_CXX_COMPILER "${MPI_CXX_COMPILER}")
include_directories(${MPI_CXX_INCLUDE_PATH})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MPI_CXX_COMPILE_FLAGS}")
add_definitions(-DPLB_MPI_PARALLEL)
endif()
endif()
if(WIN32)
option(ENABLE_POSIX "Enable POSIX" OFF)
else()
option(ENABLE_POSIX "Enable POSIX" ON)
endif()
if(ENABLE_POSIX)
message("Enabling POSIX")
add_definitions(-DPLB_USE_POSIX)
endif()
if(APPLE)
add_definitions(-DPLB_MAC_OS_X)
endif()
if(WIN32 OR CYGWIN)
add_definitions(-DPLB_WINDOWS)
endif()
###############################################################################
# Palabos Library
###############################################################################
include_directories("../palabos-v2.2.1/src")
include_directories("../palabos-v2.2.1/externalLibraries")
include_directories("../palabos-v2.2.1/externalLibraries/Eigen3")
file(GLOB_RECURSE PALABOS_SRC "../palabos-v2.2.1/src/*.cpp")
file(GLOB_RECURSE EXT_SRC "../palabos-v2.2.1/externalLibraries/tinyxml/*.cpp")
add_library(palabos STATIC ${PALABOS_SRC} ${EXT_SRC})
###############################################################################
add_executable(${EXECUTABLE_NAME} "./${EXECUTABLE_NAME}.cpp")
# Link with the following libraries
target_link_libraries(${EXECUTABLE_NAME} palabos)
if(ENABLE_MPI)
target_link_libraries(${EXECUTABLE_NAME} ${MPI_CXX_LIBRARIES})
endif()