Pulse.cmake 6.36 KB
Newer Older
Aaron Bray's avatar
Aaron Bray committed
1
project(Pulse)
2

Aaron Bray's avatar
Aaron Bray committed
3
4
5
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)

# Policy to address @foo@ variable expansion
6
set(PULSE_VERSION_MAJOR 1)
Aaron Bray's avatar
Aaron Bray committed
7
set(PULSE_VERSION_MINOR 1)
8
9
set(PULSE_VERSION_PATCH 0)
set(PULSE_VERSION "${PULSE_VERSION_MAJOR}.${PULSE_VERSION_MINOR}.${PULSE_VERSION_PATCH}")
10

11
12
# Build the core libraries as shared or static (DataModel, CDM, Engine)
set(BUILD_SHARED_LIBS OFF)
Aaron Bray's avatar
Aaron Bray committed
13
set(CMAKE_CXX_STANDARD 11)
14
15
16

set(PULSE_DEBUG_POSTFIX "d")
set(PULSE_RELWITHDEBINFO_POSTFIX "di")
17

abray's avatar
abray committed
18
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
19
set(CMAKE_CONFIGURATION_TYPES "Debug" "Release" "RelWithDebInfo" CACHE STRING INTERNAL FORCE )
20
if(MSVC)  
Aaron Bray's avatar
Aaron Bray committed
21
# Using MD as that seems to be what I run into alot, you could change these to /MT and /MTd if you want...
22
23
24
  set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /MDd /Zi /Ob2 /Oi /Od /RTC1 /MP" CACHE STRING INTERNAL FORCE)
  set(CMAKE_CXX_FLAGS_RELEASE "/MD /MP" CACHE STRING INTERNAL FORCE)
  set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/MDd /Zi /MP" CACHE STRING INTERNAL FORCE)
25
26
27
endif()

if(MINGW)
Aaron Bray's avatar
Aaron Bray committed
28

29
30
31
endif()

if(APPLE)
Aaron Bray's avatar
Aaron Bray committed
32

33
34
35
endif()

if(UNIX)
Aaron Bray's avatar
Aaron Bray committed
36
  set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_RPATH}:\$ORIGIN")
37
38
endif()

39
40
41
42
43
44
45
46
47
if ( CMAKE_COMPILER_IS_GNUCC )
  # Protobuf is not using the same variable name in its swap specificiation definitions
  # Resulting in a LOT of warnings per file that includes protobuf headers, slowing the build down
  set(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -Wno-attributes")
  if(CMAKE_BUILD_TYPE EQUAL "Debug")
    set(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} -Wa,-mbig-obj")
  endif()
endif()

48
49


50
message(STATUS "Looking for modules here : ${CMAKE_PREFIX_PATH}")
51
52
set(CMAKE_CXX_STANDARD_LIBRARIES "" CACHE STRING INTERNAL FORCE)
set(CMAKE_C_STANDARD_LIBRARIES "" CACHE STRING INTERNAL FORCE)
53
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX})
54

55
find_package(Eigen3 REQUIRED)
56
57
58
59
60

if(WIN32)
  find_package(Dirent REQUIRED)
endif()

61
62
# The outer build does some custom installing of dependent libraries
# Instead of using find_package, I will make sure things are where expected
63
64
65
66
67
68
69
if(NOT protobuf_SRC)
  set(protobuf_SRC ${CMAKE_BINARY_DIR}/../protobuf/src/protobuf)
endif()
set(protobuf_Header ${protobuf_SRC}/src/google/protobuf/package_info.h)
# Proto headers should have been installed here by the outer build
if(NOT EXISTS ${protobuf_Header})
  message(FATAL_ERROR "I cannot find protobuf source, please set protobuf_SRC to its root directory")
70
endif()
71
72
73
74
if(NOT protobuf_INSTALL)
  set(protobuf_INSTALL ${CMAKE_BINARY_DIR}/../protobuf/install)
endif()
list(APPEND CMAKE_PREFIX_PATH ${protobuf_INSTALL})
Aaron Bray's avatar
Aaron Bray committed
75
# log4cplus src should have been download to somewhere
76
if(NOT log4cplus_SRC)
77
  # It should be here if the outer build ran
78
  set(log4cplus_SRC ${CMAKE_BINARY_DIR}/../log4cplus/src/log4cplus)
79
endif()
80
81
82
83
84
85
set(log4cplus_HEADER ${log4cplus_SRC}/include/log4cplus/logger.h)
if(NOT EXISTS ${log4cplus_HEADER})
  message(FATAL_ERROR "I cannot find log4cplus source, please set log4cplus_SRC to its root directory")
endif()
list(APPEND LOG4CPLUS_INCLUDE_DIR ${log4cplus_SRC}/include)
list(APPEND LOG4CPLUS_INCLUDE_DIR ${log4cplus_SRC}-build/include)
86

87
set(SCHEMA_SRC "${CMAKE_SOURCE_DIR}/schema")
88
set(SCHEMA_DST "${CMAKE_SOURCE_DIR}/schema/bind")
Aaron Bray's avatar
Aaron Bray committed
89
# Settings for protobuf configuration
90
91
92
93
94
set(protobuf_BUILD_PROTOC_BINARIES OFF CACHE BOOL INTERNAL FORCE)
set(protobuf_BUILD_SHARED_LIBS OFF CACHE BOOL INTERNAL FORCE)
set(protobuf_MSVC_STATIC_RUNTIME OFF CACHE BOOL INTERNAL FORCE)#Use our MSVC runtime settings (/MD or /MT)
set(protobuf_BUILD_TESTS OFF CACHE BOOL INTERNAL FORCE)
set(protobuf_BUILD_EXAMPLES OFF CACHE BOOL INTERNAL FORCE)
95
add_subdirectory("${protobuf_SRC}/cmake" "${protobuf_SRC}-build")
Aaron Bray's avatar
Aaron Bray committed
96
# Setting for log4cplus configuration
97
98
99
100
101
102
set(UNICODE OFF CACHE BOOL INTERNAL FORCE)
set(LOG4CPLUS_SINGLE_THREADED OFF CACHE BOOL INTERNAL FORCE)
set(LOG4CPLUS_BUILD_LOGGINGSERVER OFF CACHE BOOL INTERNAL FORCE)
set(LOG4CPLUS_BUILD_TESTING OFF CACHE BOOL INTERNAL FORCE)
set(LOG4CPLUS_ENABLE_DECORATED_LIBRARY_NAME OFF CACHE BOOL INTERNAL FORCE)
set(WITH_UNIT_TESTS OFF CACHE BOOL INTERNAL FORCE)
Aaron Bray's avatar
Aaron Bray committed
103
# Get log4cplus to install to a location so we can customize the install for Pulse
104
add_subdirectory(${log4cplus_SRC} ${log4cplus_SRC}-build)
Aaron Bray's avatar
Aaron Bray committed
105
# Include the rest of the Pulse projects
106
107
108
109
add_subdirectory(schema)
add_subdirectory(cdm)
add_subdirectory(engine)
add_subdirectory(test)
110
add_subdirectory(sdk)
Aaron Bray's avatar
Aaron Bray committed
111
add_subdirectory(verification)
112
# Various interfaces for different languages
113
include(${CMAKE_CURRENT_SOURCE_DIR}/PulseC.cmake)
Aaron Bray's avatar
Aaron Bray committed
114
include(${CMAKE_CURRENT_SOURCE_DIR}/PulseCLR.cmake)
115
include(${CMAKE_CURRENT_SOURCE_DIR}/PulseJNI.cmake)
Aaron Bray's avatar
Aaron Bray committed
116

117
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
118
set_target_properties (libprotobuf libprotobuf-lite PROPERTIES FOLDER protobufs)
Aaron Bray's avatar
Aaron Bray committed
119

120

121
122
123
124
file(COPY ${CMAKE_SOURCE_DIR}/bin DESTINATION ${CMAKE_INSTALL_PREFIX})
configure_file(${CMAKE_SOURCE_DIR}/bin/run.cmake.in ${CMAKE_INSTALL_PREFIX}/bin/run.cmake @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/bin/run.config.in ${CMAKE_INSTALL_PREFIX}/bin/run.config @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/docs/Doxygen/full.doxy.in ${CMAKE_INSTALL_PREFIX}/bin/docs/full.doxy @ONLY)
125
configure_file(${CMAKE_SOURCE_DIR}/cmake/PulseConfig.cmake.in ${CMAKE_INSTALL_PREFIX}/PulseConfig.cmake @ONLY)
Aaron Bray's avatar
Aaron Bray committed
126
configure_file(${CMAKE_SOURCE_DIR}/bin/Rebase.py.in ${CMAKE_INSTALL_PREFIX}/bin/Rebase.py @ONLY)
127

128
# Pulse Testing
Aaron Bray's avatar
Aaron Bray committed
129
130
enable_testing()
add_test(NAME runCDMUnitTests
131
  COMMAND ${CMAKE_COMMAND} -DTYPE:STRING=CDMUnitTests -P ${CMAKE_BINARY_DIR}/install/bin/run.cmake
Aaron Bray's avatar
Aaron Bray committed
132
133
  WORKING_DIRECTORY ${INSTALL_BIN})
add_test(NAME runBGEUnitTests
Aaron Bray's avatar
Aaron Bray committed
134
  COMMAND ${CMAKE_COMMAND} -DTYPE:STRING=EngineUnitTests -P ${CMAKE_BINARY_DIR}/install/bin/run.cmake
Aaron Bray's avatar
Aaron Bray committed
135
136
  WORKING_DIRECTORY ${INSTALL_BIN})
add_test(NAME runSystemValidation
137
  COMMAND ${CMAKE_COMMAND} -DTYPE:STRING=SystemValidation -P ${CMAKE_BINARY_DIR}/install/bin/run.cmake
Aaron Bray's avatar
Aaron Bray committed
138
139
  WORKING_DIRECTORY ${INSTALL_BIN})
add_test(NAME runPatientValidation
140
  COMMAND ${CMAKE_COMMAND} -DTYPE:STRING=PatientValidation -P ${CMAKE_BINARY_DIR}/install/bin/run.cmake
Aaron Bray's avatar
Aaron Bray committed
141
142
  WORKING_DIRECTORY ${INSTALL_BIN})
add_test(NAME runVerification
143
  COMMAND ${CMAKE_COMMAND} -DTYPE:STRING=VerificationScenarios -P ${CMAKE_BINARY_DIR}/install/bin/run.cmake
Aaron Bray's avatar
Aaron Bray committed
144
145
  WORKING_DIRECTORY ${INSTALL_BIN})
add_test(NAME runDrugValidation
146
  COMMAND ${CMAKE_COMMAND} -DTYPE:STRING=ValidationDrugs -P ${CMAKE_BINARY_DIR}/install/bin/run.cmake
Aaron Bray's avatar
Aaron Bray committed
147
148
  WORKING_DIRECTORY ${INSTALL_BIN})
add_test(NAME runLongVerification
149
  COMMAND ${CMAKE_COMMAND} -DTYPE:STRING=LongVerificationScenarios -P ${CMAKE_BINARY_DIR}/install/bin/run.cmake
Aaron Bray's avatar
Aaron Bray committed
150
  WORKING_DIRECTORY ${INSTALL_BIN})
151
# TODO Make Doc generation a test too!