-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
executable file
·85 lines (67 loc) · 3.05 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
project(aspherix_cosim_socket CXX)
cmake_minimum_required(VERSION 3.1)
if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# setting this so that there are no issues with open foam
OPTION(SKIP_MPICXX "Skip mpicxx (recommended for OpenFOAM/Coupling compilations)" ON)
if (${SKIP_MPICXX})
OPTION(MPI_CXX_SKIP_MPICXX "Skip mpicxx (recommended for OpenFOAM/Coupling compilations)" ON)
set(CMAKE_CXX_FLAGS "-DMPICH_SKIP_MPICXX -DOMPI_SKIP_MPICXX")
else()
OPTION(MPI_CXX_SKIP_MPICXX "Skip mpicxx (recommended for OpenFOAM/Coupling compilations)" OFF)
endif()
#set verbose Makefile to double check mpicxx
set(CMAKE_VERBOSE_MAKEFILE ON)
set(SOURCE aspherix_cosim_socket.cpp)
OPTION(STATIC_LIBRARY "Compile as static library" OFF)
if (STATIC_LIBRARY)
add_library(aspherix_cosim_socket STATIC ${SOURCE})
else()
add_library(aspherix_cosim_socket SHARED ${SOURCE})
endif()
set_property(TARGET aspherix_cosim_socket PROPERTY PUBLIC_HEADER aspherix_cosim_socket.h)
OPTION(STATIC_LIBSTDCPP "Build with statically linked C++ standard library" OFF)
set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Build type. Can be Debug or Release." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
if(STATIC_LIBSTDCPP)
message(STATUS "enabling static linking of libstdc++ and libgcc")
target_link_libraries(aspherix_cosim_socket -static-libstdc++)
target_link_libraries(aspherix_cosim_socket -static-libgcc)
endif()
#=============================================================
FIND_PACKAGE(MPI)
IF(MPI_FOUND)
INCLUDE_DIRECTORIES(${MPI_INCLUDE_PATH})
target_link_libraries(aspherix_cosim_socket ${MPI_LIBRARIES})
IF(MPI_COMPILE_FLAGS)
set_property(TARGET aspherix_cosim_socket
APPEND PROPERTY COMPILE_FLAGS "${MPI_COMPILE_FLAGS}")
ENDIF()
IF(MPI_LINK_FLAGS)
set_property(TARGET aspherix_cosim_socket
APPEND PROPERTY LINK_FLAGS "${MPI_LINK_FLAGS}")
ENDIF()
ELSE(MPI_FOUND)
MESSAGE(SEND_ERROR "MPI not found. Will continue processing cmake, but not build library.")
ENDIF(MPI_FOUND)
#=============================================================
install(TARGETS aspherix_cosim_socket DESTINATION lib
PUBLIC_HEADER DESTINATION include/aspherix_cosim_socket)
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/aspherix_cosim_socketConfig.cmake")
install(FILES ${SOURCE} DESTINATION include/aspherix_cosim_socket)
install(FILES CMakeLists.txt DESTINATION include/aspherix_cosim_socket)
install(FILES compileLib.sh DESTINATION include/aspherix_cosim_socket)
install(FILES aspherix_cosim_socketConfig.cmake DESTINATION share/aspherix_cosim_socket)
install(FILES license.txt DESTINATION share/aspherix_cosim_socket)
endif()