File: CMakeLists.txt.template

package info (click to toggle)
dune-common 2.11.0-1~exp2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 6,056 kB
  • sloc: cpp: 54,404; python: 4,136; sh: 1,657; makefile: 17
file content (84 lines) | stat: -rw-r--r-- 2,725 bytes parent folder | download | duplicates (4)
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
# SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
# SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception

cmake_minimum_required(VERSION 3.16)

# acquire lock to avoid cmake raise conditions

# This is the CMakeLists.txt of the dune-py module. As new targets are
# created when ever new bindings are required, a simple make call
# might trigger a cmake reconfiguration. If different python scripts
# run in parallel, we might have different parallel make calls and as
# a consequence also parallel cmake calls.  Parallel cmake calls are
# not allowed and as a consequence the complete build may fail. We
# take care of such parallel cmake calls by additional locking in the
# dune-py CMakeLists.txt
set(lock "${CMAKE_BINARY_DIR}/cmake.lock")
message("---- LOCK")
file(LOCK ${lock})
message("---- ACQUIRED")

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_PREFIX_PATH {{ install_prefix }})

{% for mod, dir in builddirs.items() -%}
{% if dir != "" %}
set({{ mod }}_DIR {{ dir }})
{% endif %}
{%- endfor %}

{% for flag, value in cmake_flags.items() -%}
# ENABLE_HEADERCHECK cannot be set in dune-py since this will simply not work
{% if flag != "" and flag != "ENABLE_HEADERCHECK" %}
# boolean flags need to be forced to be written to the cache
# otherwise they will be overwritten by the default from dune-common
{% if value == True %}
set({{ flag }} TRUE CACHE BOOL "stored user config {{flag}}" FORCE)
{% elif value == False %}
set({{ flag }} FALSE CACHE BOOL "stored user config {{flag}}" FORCE)
{% else %}
set({{ flag }} "{{ value }}")
{% endif %}
{% endif %}
{%- endfor %}

project(dune-py C CXX)

if(NOT (dune-common_DIR OR dune-common_ROOT OR "${CMAKE_PREFIX_PATH}" MATCHES ".*dune-common.*"))
  string(REPLACE ${CMAKE_PROJECT_NAME} dune-common dune-common_DIR ${PROJECT_BINARY_DIR})
endif()

find_package(dune-common REQUIRED)
list(APPEND CMAKE_MODULE_PATH ${dune-common_MODULE_PATH})

# include(DunePythonCompiler)

include(DuneMacros)
dune_project()
dune_enable_all_packages()

add_subdirectory(python/dune/generated)
# dune_add_pybind11_module(NAME ${DUNEPY_FILE})
# dune_target_enable_all_packages(${DUNEPY_FILE})

# find bash
include(FindUnixCommands)
# find make program (might differ from CMAKE_MAKE_PROGRAM when ninja is used
find_program(MAKE make)  
# CMAKE_MAKE_PROGRAM points to either make or ninja
set( UNIXCMD_SCRIPT_FILE "[
{ 
 \"bash\" : \"${BASH}\", 
 \"make\" : \"${MAKE}\",
 \"generator\" : \"${CMAKE_MAKE_PROGRAM}\"
}
]")

file(WRITE "${CMAKE_BINARY_DIR}/unix_commands.json" ${UNIXCMD_SCRIPT_FILE})

finalize_dune_project()

# we are done, so release lock
message("---- RELEASE")
file(LOCK ${lock} RELEASE)
message("---- DONE")