-
Notifications
You must be signed in to change notification settings - Fork 11
/
CMakeLists.txt
72 lines (61 loc) · 2.02 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
cmake_minimum_required(VERSION 3.13...3.17)
include(CMakePrintHelpers)
find_program(ccache_executable ccache)
if(ccache_executable)
message(STATUS "Using ccache: ${ccache_executable}")
set(CMAKE_CXX_COMPILER_LAUNCHER ${ccache_executable})
endif()
find_program(mold_executable mold)
find_program(
gxx_executable
NAMES g++-20
g++-19
g++-18
g++-17
g++-16
g++-15
g++-14
g++-13
g++-12
g++-11
g++-10
g++-9
g++-8)
if(mold_executable AND gxx_executable)
message(STATUS "Using mold: ${mold_executable}")
add_compile_options(-fuse-ld=mold)
set(CMAKE_CXX_COMPILER ${gxx_executable})
endif()
project(pyhepmc LANGUAGES CXX)
if(GCC)
# HepMC3 uses reinterpret_cast instead of const_cast
add_compile_options(-Wno-strict-aliasing)
endif()
set(CMAKE_CXX_STANDARD
14
CACHE STRING "C++ version selection")
set(CMAKE_CXX_STANDARD_REQUIRED ON) # optional, ensure standard is supported
set(CMAKE_CXX_EXTENSIONS OFF) # optional, keep compiler extensions off
# Now we can find pybind11
option(EXTERNAL_PYBIND11 "Build against an external pybind11" OFF)
if(EXTERNAL_PYBIND11)
find_package(pybind11 CONFIG REQUIRED)
else()
add_subdirectory(extern/pybind11)
endif()
cmake_print_variables(CMAKE_BUILD_TYPE)
file(GLOB SOURCES "src/*.cpp")
file(GLOB HEPMC3_SOURCES "extern/HepMC3/src/*.cc")
# pyhepmc falls under Section 5 "Combined Libraries" of the LGPL-v3. Since we
# satisfy a) and b), we do not need to compile the code into a separate library.
pybind11_add_module(_core MODULE ${SOURCES} ${HEPMC3_SOURCES})
target_include_directories(_core PRIVATE extern/cpp-member-accessor/include)
target_include_directories(_core PRIVATE extern/mp11/include)
target_include_directories(_core PRIVATE extern/HepMC3/include)
target_compile_definitions(_core PRIVATE HepMC3_EXPORTS=1)
if(MSVC)
target_compile_options(_core PRIVATE /bigobj)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
else()
target_compile_options(_core PRIVATE -Wall -Wno-self-assign-overloaded)
endif()