CMakeLists.txt 4.21 KB
Newer Older
1
2
3
cmake_minimum_required(VERSION 3.5)
project(DPsim CXX)

4
5
6
7
8
9
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
	set(TOPLEVEL_PROJECT ON)
else()
		set(TOPLEVEL_PROJECT OFF)
endif()

Steffen Vogel's avatar
Steffen Vogel committed
10
# Enable C++11 support
11
set(CMAKE_CXX_STANDARD 11)
Georg Martin Reinke's avatar
Georg Martin Reinke committed
12
13
14
15
if(CMAKE_CXX_COMPILER_ID STREQUAL Intel)
	# needed by icc, but for some reason not added by CMake
	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
Markus Mirz's avatar
Markus Mirz committed
16
add_definitions(-D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS)
17

18
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake;${PROJECT_SOURCE_DIR}/Dependencies/libcps/CMake")
19

20
21
set(PROJECT_AUTHOR "Institute for Automation of Complex Power Systems, RWTH Aachen University")
set(PROJECT_COPYRIGHT "2017, Institute for Automation of Complex Power Systems, RWTH Aachen University")
22

23
include(CheckCXXCompilerFlag)
Markus Mirz's avatar
Markus Mirz committed
24
if(MSVC)	
25
26
27
	check_cxx_compiler_flag("/W4 /WX" CXX_SUPPORTS_WERROR)

	if(CXX_SUPPORTS_WERROR)
Markus Mirz's avatar
Markus Mirz committed
28
29
	# TODO activate this again after fixing warnings
	#		set(DPSIM_CXX_FLAGS /W4 /WX)
30
31
32
33
34
35
36
37
	endif()
else()
	check_cxx_compiler_flag("-Wall -Werror" CXX_SUPPORTS_WERROR)

	if(CXX_SUPPORTS_WERROR)
		set(DPSIM_CXX_FLAGS -Wall -Werror)
	endif()
endif()
38

39
40
41
include(CheckSymbolExists)
check_symbol_exists(pipe unistd.h HAVE_PIPE)
check_symbol_exists(timerfd_create sys/timerfd.h HAVE_TIMERFD)
Steffen Vogel's avatar
Steffen Vogel committed
42
check_symbol_exists(getopt_long getopt.h HAVE_GETOPT)
43

44
45
46
# Get version info and buildid from Git
include(GetVersion)
GetVersion(${PROJECT_SOURCE_DIR} "DPSIM")
47

Markus Mirz's avatar
Markus Mirz committed
48
49
add_subdirectory(Dependencies/libcps)

50
51
find_package(PythonInterp 3.6)
find_package(PythonLibs 3.6)
52
find_package(Sundials)
53
find_package(OpenMP)
Jan Dinkelbach's avatar
add GSL    
Jan Dinkelbach committed
54
find_package(GSL)
55

56
57
58
59
60
option(WITH_VILLAS "Build with VILLAS Interface" OFF)
if (WITH_VILLAS)
	find_package(VILLASnode)
endif()

Steffen Vogel's avatar
Steffen Vogel committed
61
62
63
64
65
66
if(PythonInterp_FOUND AND PythonLibs_FOUND)
	set(Python_FOUND ON)
endif()

if("${CMAKE_SYSTEM}" MATCHES "Linux")
	set(Linux_FOUND ON)
67
68
endif()

Steffen Vogel's avatar
Steffen Vogel committed
69
70
# Options
option(BUILD_SHARED_LIBS "Build shared library" OFF)
71
option(BUILD_EXAMPLES "Build C++ examples" ON)
72
option(COMPARE_REFERENCE "Download reference results and compare" OFF)
Steffen Vogel's avatar
Steffen Vogel committed
73

Steffen Vogel's avatar
Steffen Vogel committed
74
option(WITH_GSL      "Enable GSL"                           ${GSL_FOUND})
75
option(WITH_SUNDIALS "Enable sundials solver suite"         ${Sundials_FOUND})
76
option(WITH_SHMEM    "Enable shared memory interface"       ${VILLASnode_FOUND})
77
option(WITH_RT	     "Enable real-time features"            ${Linux_FOUND})
78
79
option(WITH_PYTHON   "Enable Python support"                ${Python_FOUND})
option(WITH_CIM      "Enable support for parsing CIM files" ${CIMpp_FOUND})
80
option(WITH_OPENMP   "Enable OpenMP-based parallelisation"  ${OPENMP_FOUND})
81
82

configure_file(
83
84
	${CMAKE_CURRENT_SOURCE_DIR}/Include/dpsim/Config.h.in
	${CMAKE_CURRENT_BINARY_DIR}/Include/dpsim/Config.h
85
86
87
)

set(INCLUDE_DIRS
88
89
	${CMAKE_CURRENT_BINARY_DIR}/Include
	${CMAKE_CURRENT_SOURCE_DIR}/Include
90
91
)

92
add_subdirectory(Tests)
93
add_subdirectory(Source)
94
add_subdirectory(Documentation)
Markus Mirz's avatar
Markus Mirz committed
95

96
if(BUILD_EXAMPLES)
97
	add_subdirectory(Examples)
98
endif(BUILD_EXAMPLES)
99

100
101
102
103
104
105
106
107
108
109
110
if(COMPARE_REFERENCE)
	include(ExternalProject)
	ExternalProject_Add(reference-results
	  GIT_REPOSITORY    https://git.rwth-aachen.de/acs/public/simulation/reference-results.git
	  #GIT_TAG           origin/master
	  PREFIX			reference-results
	  CONFIGURE_COMMAND	""
	  BUILD_COMMAND		""
	  INSTALL_COMMAND	""
	)
endif()
Steffen Vogel's avatar
Steffen Vogel committed
111

112
113
114
115
116
117
118
119
if(TOPLEVEL_PROJECT)
	# Show feature summary
	include(FeatureSummary)

	add_feature_info(CIM	WITH_CIM	"Loading Common Information Model Files")
	add_feature_info(Python WITH_PYTHON "Use DPsim as a Python module")
	add_feature_info(Shmem  WITH_SHMEM  "Interface DPsim solvers via shared-memory interfaces")
	add_feature_info(RT	    WITH_RT     "Extended real-time features")
Jan Dinkelbach's avatar
add GSL    
Jan Dinkelbach committed
120
	add_feature_info(GSL	WITH_GSL     "Use GNU Scientific library")
121
122
	feature_summary(WHAT ALL VAR enabledFeaturesText)

123
	message(STATUS "Building ${CMAKE_PROJECT_NAME}:")
124
125
126
127
128
129
130
131
132
133
	message(STATUS "Feature summary for DPsim")
	message(STATUS "${enabledFeaturesText}")
    message(STATUS "  VERSION:         ${DPSIM_VERSION}")
    message(STATUS "  RELEASE:         ${DPSIM_RELEASE}")
    message(STATUS "  GIT_REV:         ${DPSIM_GIT_REV}")
    message(STATUS "  GIT_BRANCH:      ${DPSIM_GIT_BRANCH}")
    message(STATUS "  VARIANT:         ${DPSIM_VARIANT}")
    message(STATUS "  BUILD_ID:        ${DPSIM_BUILD_ID}")
    message(STATUS "  BUILD_DATE:      ${DPSIM_BUILD_DATE}")
endif()
134

Steffen Vogel's avatar
Steffen Vogel committed
135
include(DPsimPackaging)