forked from ihedvall/mdflib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
126 lines (106 loc) · 3.84 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# Copyright 2021 Ingemar Hedvall
# SPDX-License-Identifier: MIT
include(CMakePrintHelpers)
cmake_minimum_required(VERSION 3.10)
cmake_policy(SET CMP0074 NEW)
cmake_policy(SET CMP0144 NEW)
if("${CMAKE_TOOLCHAIN_FILE}" STREQUAL "")
set(VCPKG OFF)
else()
set(VCPKG ON)
endif()
option(BUILD_SHARED_LIBS "Build static library as default." OFF)
option(MDF_BUILD_SHARED_LIB "Build shared library." ON)
option(MDF_BUILD_SHARED_LIB_NET "Build shared library with .NET." OFF) # Only for MSVC 19.36+
option(MDF_BUILD_SHARED_LIB_EXAMPLE "Build shared library example." OFF)
option(MDF_BUILD_DOC "Build documentation. Requires Doxygen and Release mode." OFF)
option(MDF_BUILD_TOOL "Build tools like the MDF Viewer. Requires WxWidgets." OFF)
option(MDF_BUILD_TEST "Build Google Unit Tests. Requires Google Test." OFF)
option(MDF_BUILD_PYTHON "Build Python module" OFF)
if(MDF_BUILD_TOOL AND VCPKG)
# Boost & wxWidgets need /MT for static linking
# string(REPLACE "-static" "" VCPKG_TARGET_TRIPLET "${VCPKG_TARGET_TRIPLET}")
list(APPEND VCPKG_MANIFEST_FEATURES "mdf2csv")
list(APPEND VCPKG_MANIFEST_FEATURES "mdfviewer")
endif()
if(MDF_BUILD_TEST AND VCPKG)
# GTest need /MT for static linking
# string(REPLACE "-static" "" VCPKG_TARGET_TRIPLET "${VCPKG_TARGET_TRIPLET}")
list(APPEND VCPKG_MANIFEST_FEATURES "mdflibtest")
endif()
project(
mdflib
VERSION 2.2
DESCRIPTION "Interface against MDF 3/4 files"
LANGUAGES CXX)
add_subdirectory(mdflib)
if(MDF_BUILD_SHARED_LIB)
if(NOT (MSVC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.36))
set(MDF_BUILD_SHARED_LIB_NET OFF)
endif()
add_subdirectory(mdflibrary)
endif()
if(MDF_BUILD_TEST)
enable_testing()
add_subdirectory(mdflib_test)
endif()
if(MDF_BUILD_SHARED_LIB AND MDF_BUILD_SHARED_LIB_EXAMPLE)
add_subdirectory(mdflibrary_example)
endif()
if(MDF_BUILD_TOOL)
add_subdirectory(mdf2csv)
add_subdirectory(mdfviewer)
endif()
if (MDF_BUILD_PYTHON)
find_package(Python3 COMPONENTS Interpreter Development)
cmake_print_properties(TARGETS Python3::Python PROPERTIES
NAME
LOCATION
INTERFACE_INCLUDE_DIRECTORIES)
cmake_print_variables(
Python3_FOUND
Python3_INCLUDE_DIRS
Python3_RUNTIME_LIBRARY_DIRS)
include("script/pybind11.cmake")
add_subdirectory(python)
endif()
if((CMAKE_BUILD_TYPE MATCHES "^[Rr]elease") AND MDF_BUILD_DOC)
include("script/doxygen.cmake")
if(DOXYGEN_FOUND)
set(DOXYGEN_RECURSIVE NO)
set(DOXYGEN_REPEAT_BRIEF NO)
set(DOXYGEN_PROJECT_NAME "MDF Lib")
set(DOXYGEN_PROJECT_NUMBER "2.2")
set(DOXYGEN_HTML_EXTRA_STYLESHEET doxygen/utillib.css)
set(DOXYGEN_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/docs/manual)
doxygen_add_docs(
doc_libmdf ALL include/mdf doxygen
COMMENT "MDF Library generating API documentation with Doxygen")
endif()
endif()
# ##############################################################################
# Packaging
# ##############################################################################
# https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#creating-a-package-configuration-file
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/mdflib/mdflibConfigVersion.cmake"
VERSION ${Upstream_VERSION}
COMPATIBILITY AnyNewerVersion)
export(
EXPORT MdfLibTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/mdflib/mdflibTargets.cmake"
NAMESPACE Upstream::)
configure_file(cmake/MdfLibConfig.cmake
"${CMAKE_CURRENT_BINARY_DIR}/mdflib/MdfLibConfig.cmake" COPYONLY)
set(ConfigPackageLocation lib/cmake/mdflib)
install(
EXPORT MdfLibTargets
FILE MdfLibTargets.cmake
NAMESPACE Upstream::
DESTINATION ${ConfigPackageLocation})
install(
FILES cmake/MdfLibConfig.cmake
"${CMAKE_CURRENT_BINARY_DIR}/mdflib/mdflibConfigVersion.cmake"
DESTINATION ${ConfigPackageLocation}
COMPONENT Devel)