-
Notifications
You must be signed in to change notification settings - Fork 54
/
CMakeLists.txt
87 lines (71 loc) · 2.88 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
cmake_minimum_required(VERSION 3.17.0)
cmake_policy(VERSION 3.17.0)
if ( "x${MCVERSION}" STREQUAL "x" )
set(MCVERSION 3.99.999)
message(WARNING "Build version was unset. Define using e.g. -DMCVERSION=${MCVERSION}")
endif()
# This file will build McStas and/or McXtrace
project(mccode LANGUAGES C VERSION "${MCVERSION}")
set(CMAKE_C_STANDARD 99)
# Stash the project version for use in C macro comparisons
math(EXPR MCCODE_VERSION_MACRO "(${CMAKE_PROJECT_VERSION_MAJOR} * 100 + ${CMAKE_PROJECT_VERSION_MINOR}) * 1000 + ${CMAKE_PROJECT_VERSION_PATCH}" OUTPUT_FORMAT DECIMAL)
# Set module path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
#Ensure various variables are set to sensible default values for the target
#platform (if not already set by a toolchain file):
option( BUILD_MCSTAS "Build McStas" OFF )
option( BUILD_MCXTRACE "Build McXtrace" OFF )
option( BUILD_TOOLS "Include tools" ON )
option( BUILD_MCXRUN "Include mcrun/mxrun even if BUILD_TOOLS is OFF" )#fixme: replace with more fine-grained control
option( ENABLE_COMPONENTS "Whether or not to include comps and instruments" ON )
option( EXCLUDE_CONTRIB "Whether or not to exclude contrib comps" OFF )#fixme: replace with more fine-grained control
option( EXCLUDE_DATA "Whether or not to exclude data files" OFF )#fixme: replace with more fine-grained control
if ( BUILD_MCSTAS AND BUILD_MCXTRACE )
message(WARNING "Configuration requests building both McStas and McXtrace which is likely to fail.")
elseif( NOT BUILD_MCSTAS AND NOT BUILD_MCXTRACE )
message(FATAL_ERROR "Configuration requires building one of McStas or McXtrace via -DBUILD_MCXTRACE=ON or -DBUILD_MCSTAS=ON")
endif()
# Setup McCode values (from mkdist or defaults)
include(MCUtil)
if ( BUILD_MCSTAS )
option( ENSURE_NCRYSTAL "Build Third Party code NCrystal if not already available" ON )
if ( ENSURE_NCRYSTAL )
set ( NCRYSTAL_LEGACY_USE 1 )
else()
set ( NCRYSTAL_LEGACY_USE 0 )
endif()
endif()
if( BUILD_MCSTAS )
setupMCCODE("mcstas")
message(STATUS "Configuring McStas build ${FLAVOR}")
add_subdirectory(mcstas)
if ( ENABLE_COMPONENTS )
add_subdirectory(mcstas-comps)
endif()
add_subdirectory(docpkg/manuals/mcstas)
endif()
if ( BUILD_MCXTRACE )
setupMCCODE("mcxtrace")
message(STATUS "Configuring McXtrace build ${FLAVOR}")
add_subdirectory(mcxtrace)
if ( ENABLE_COMPONENTS )
add_subdirectory(mcxtrace-comps)
endif()
add_subdirectory(docpkg/manuals/mcxtrace)
endif()
if ( BUILD_TOOLS )
add_subdirectory( tools )
elseif ( BUILD_MCXRUN )
add_subdirectory( tools/Python/mcrun )
add_subdirectory( tools/Python/mccodelib)
endif()
# Find/Fetch dependencies:
option( ENSURE_MCPL "Build Third Party code MCPL if not already available" ON )
if( ENSURE_MCPL )
include( MCPL )
endif()
if( BUILD_MCSTAS )
if ( ENSURE_NCRYSTAL )
include( NCrystal )
endif()
endif()