-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
79 lines (68 loc) · 2.58 KB
/
CMakeLists.txt
File metadata and controls
79 lines (68 loc) · 2.58 KB
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
cmake_minimum_required(VERSION 3.10)
find_program(VCPKG_EXECUTABLE vcpkg)
if(VCPKG_EXECUTABLE)
get_filename_component(VCPKG_ROOT ${VCPKG_EXECUTABLE} DIRECTORY)
message(STATUS "Found vcpkg at: ${VCPKG_ROOT}")
if(WIN32)
set(VCPKG_TARGET_TRIPLET "x64-windows")
elseif(APPLE)
set(VCPKG_TARGET_TRIPLET "x64-osx")
else()
set(VCPKG_TARGET_TRIPLET "x64-linux")
endif()
set(CMAKE_TOOLCHAIN_FILE "${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "")
else()
message(STATUS "vcpkg not found in PATH, using system provided libraries.")
endif()
project(crispy)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-header-filter='^(?!.*(ext|vcpkg_installed)).*'")
set(CMAKE_CXX_CLANG_TIDY_CHECKS "-*,modernize-*,-modernize-use-trailing-return-type,-performance-*")
# cache previous compilations to speed up recompilation if ccache available
find_program(CACHE_FOUND ccache)
if(CACHE_FOUND)
set(CMAKE_CXX_COMPILER_LAUNCHER ${CACHE_FOUND})
message(STATUS "Found ccache: ${CACHE_FOUND} (enabled for C++)")
else()
message(STATUS "ccache not found (compiler caching disabled)")
endif()
add_compile_definitions(RESOURCE_PATH="${CMAKE_SOURCE_DIR}/resources")
add_subdirectory(src)
option(BUILD_TESTING "Enable building of testing suite" ON)
option(BUILD_DOCS "Enable building of documentation" ON)
option(BUILD_PYTHON "Enable building of Python bindings" ON)
if(BUILD_TESTING)
find_package(Catch2 REQUIRED)
include(CTest)
include(Catch)
add_subdirectory(tests/lib)
endif()
if(BUILD_DOCS)
add_subdirectory(docs)
endif()
if(BUILD_PYTHON)
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
set(PYBIND11_FINDPYTHON ON)
find_package(pybind11 REQUIRED)
pybind11_add_module(_crispy "src/binder/binder.cpp")
target_link_libraries(_crispy PRIVATE crispy)
target_include_directories(crispy PRIVATE ${Python_INCLUDE_DIRS})
add_custom_command(TARGET _crispy POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:_crispy> ${CMAKE_CURRENT_SOURCE_DIR}/src/crispy/
COMMENT "Copying _crispy module to src/crispy"
)
if(WIN32)
add_custom_command(TARGET _crispy POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo Copying DLLs to ${CMAKE_CURRENT_SOURCE_DIR}/src/crispy
COMMAND xcopy /Y /Q /S /I \"$<TARGET_FILE_DIR:_crispy>\\*.dll\" \"${CMAKE_CURRENT_SOURCE_DIR}/src/crispy\\\"
COMMENT "Copying .dll files from target dir to src/crispy"
)
endif()
endif()
add_custom_target(
format
COMMAND clang-format -i ${ALL_SOURCE_FILES} ${TEST_SOURCES}
)