-
Notifications
You must be signed in to change notification settings - Fork 11
/
CMakeLists.txt
89 lines (71 loc) · 2.82 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
#set(CMAKE_C_COMPILER "/opt/local/bin/gcc-mp-4.9")
#set(CMAKE_CXX_COMPILER "/opt/local/bin/g++-mp-4.9")
# stop if cmake version below 2.8
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
# project name
project(VinaLC)
# enable fortran, c, and c++ language
#enable_language(C CXX)
# project version
set(VERSION_MAJOR 1)
set(VERSION_MINOR 0)
set(VERSION_PATCH 0)
set(VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
set(CMAKE_BUILD_TYPE Release)
# location of additional cmake modules
#list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# detect operating system
message(STATUS "Building on a ${CMAKE_SYSTEM_NAME} system")
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
add_definitions(-DSYSTEM_LINUX)
endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
add_definitions(-DSYSTEM_DARWIN)
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
add_definitions(-DSYSTEM_WINDOWS)
endif()
# detect host processor
message(STATUS "The host processor is ${CMAKE_HOST_SYSTEM_PROCESSOR}")
# find MPI library
find_package(MPI REQUIRED)
#set(CMAKE_CXX_COMPILER ${MPI_CXX_COMPILER})
set(CMAKE_CXX_COMPILE_FLAGS ${CMAKE_CXX_COMPILE_FLAGS} ${MPI_COMPILE_FLAGS})
set(CMAKE_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS} ${MPI_LINK_FLAGS})
include_directories(${MPI_INCLUDE_PATH})
# find boost library
if (NOT DEFINED BOOST_ROOT AND
NOT DEFINED ENV{BOOST_ROOT} AND
NOT DEFINED BOOST_INCLUDEDIR AND
NOT DEFINED ENV{BOOST_INCLUDEDIR} AND
NOT DEFINED BOOST_LIBRARYDIR AND
NOT DEFINED ENV{BOOST_LIBRARYDIR})
if (APPLE)
#set(BOOST_ROOT "../../../boost/boost_1_54_0/mac")
set(BOOST_ROOT "/Users/zhang30/inst/boost_1_61_0")
elseif (WIN32)
set(BOOST_INCLUDEDIR "C:/local/boost_1_55_0")
set(BOOST_LIBRARYDIR "C:/local/boost_1_55_0/lib32-msvc-10.0")
endif()
endif()
if (APPLE OR WIN32)
set(Boost_USE_STATIC_LIBS TRUE)
endif()
find_package(Boost 1.35 REQUIRED COMPONENTS program_options system filesystem regex serialization mpi thread)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
# find zlib
find_package( ZLIB REQUIRED )
include_directories( ${ZLIB_INCLUDE_DIRS} )
# example how to set c++ compiler flags for GNU
message(STATUS "Using C++ compiler: ${CMAKE_CXX_COMPILER_ID}")
if(CMAKE_CXX_COMPILER_ID MATCHES GNU)
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unknown-pragmas -Wno-sign-compare -Woverloaded-virtual -Wwrite-strings -Wno-unused")
set(CMAKE_CXX_FLAGS_DEBUG "-g -pg -DDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_MPI")
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
add_subdirectory(src)
add_subdirectory(apps)