1 # SPDX-FileCopyrightText: Copyright 2012 Intel Corporation
2 # SPDX-License-Identifier: BSD-2-Clause
6 cmake_minimum_required(VERSION 2.8.12)
8 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
10 # Set the default location for all build artifacts to traditionally named
11 # top-level directories. CMake's default location for build artifacts varies
12 # per artifact and is hard-to-guess.
13 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
14 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
15 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
17 include(WaffleDefineOS)
18 include(WaffleFindDependencies)
19 include(Options.cmake)
20 include(WaffleDefineInternalOptions)
21 include(WaffleValidateOptions)
22 include(WaffleDefineVersion)
23 include(WaffleDefineCompilerFlags)
24 include(GNUInstallDirs)
26 if(waffle_build_tests)
30 # Require MSVC 2013 U4
31 if (MSVC AND ${CMAKE_C_COMPILER_VERSION} VERSION_LESS 18.00.31101.0)
32 message (FATAL_ERROR "Visual Studio 2013 Update 4 or later required")
35 find_package(PkgConfig)
37 # ------------------------------------------------------------------------------
38 # Targets: check, check-func, valgrind-check, valgrind-check-func
39 # ------------------------------------------------------------------------------
42 # Target 'check' runs unit tests, but no functional tests.
44 add_custom_target(check)
47 # Target 'check-func' runs functional tests as well as unit tests.
49 # The unit tests are ran first (due to the depenency on 'check'). If any unit
50 # test fails, then no functional tests run.
52 add_custom_target(check-func
56 find_program(VALGRIND_EXECUTABLE valgrind)
57 if(VALGRIND_EXECUTABLE)
58 # Runs the 'check' target under valgrind.
59 add_custom_target(valgrind-check
63 # Runs the 'check-func' target under valgrind.
64 add_custom_target(valgrind-check-func
65 DEPENDS valgrind-check check-func
69 # ------------------------------------------------------------------------------
71 # ------------------------------------------------------------------------------
76 ${CORE_FOUNDATION_FRAMEWORK}
86 add_subdirectory(third_party/threads)
90 set(THREADS_LIBRARIES threads_bundled)
93 add_subdirectory(third_party/getopt)
97 set(GETOPT_LIBRARIES getopt_bundled)
100 add_subdirectory(doc)
101 add_subdirectory(src)
102 add_subdirectory(include)
103 add_subdirectory(man)
105 if(waffle_build_tests)
106 add_subdirectory(tests)
109 if(waffle_build_examples)
110 add_subdirectory(examples)
113 # ------------------------------------------------------------------------------
114 # Install packaging files: waffle.pc WaffleConfigVersion.cmake, and
116 # ------------------------------------------------------------------------------
118 configure_file(waffle.pc.in ${waffle_libname}.pc @ONLY)
121 FILES ${CMAKE_BINARY_DIR}/${waffle_libname}.pc
122 DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
126 set(ConfigPackageLocation "${CMAKE_INSTALL_LIBDIR}/cmake/Waffle")
127 include(CMakePackageConfigHelpers)
128 write_basic_package_version_file(
129 "${CMAKE_BINARY_DIR}/cmake/Modules/WaffleConfigVersion.cmake"
130 VERSION "${waffle_version}"
131 COMPATIBILITY SameMajorVersion
134 configure_package_config_file(
135 cmake/Modules/WaffleConfig.cmake.in
136 cmake/Modules/WaffleConfig.cmake
137 INSTALL_DESTINATION "${ConfigPackageLocation}"
138 PATH_VARS CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_INCLUDEDIR
139 NO_CHECK_REQUIRED_COMPONENTS_MACRO
144 "${CMAKE_BINARY_DIR}/cmake/Modules/WaffleConfigVersion.cmake"
145 "${CMAKE_BINARY_DIR}/cmake/Modules/WaffleConfig.cmake"
146 DESTINATION "${ConfigPackageLocation}"
150 # ------------------------------------------------------------------------------
151 # Install core documentation
152 # ------------------------------------------------------------------------------
159 DESTINATION "${CMAKE_INSTALL_DOCDIR}"
163 # ------------------------------------------------------------------------------
164 # Install shell completion
165 # ------------------------------------------------------------------------------
167 find_package(bash-completion)
168 if (NOT BASH_COMPLETION_FOUND)
169 # Fallback default dir
170 set(BASH_COMPLETION_COMPLETIONSDIR
171 "${CMAKE_INSTALL_DATADIR}/bash-completion/completions/")
175 FILES "shell-completion/bash/wflinfo"
176 DESTINATION "${CMAKE_INSTALL_PREFIX}/${BASH_COMPLETION_COMPLETIONSDIR}"
177 COMPONENT shell-completion
180 # ------------------------------------------------------------------------------
182 include(WafflePrintConfigurationSummary)
184 set (CPACK_SET_DESTDIR ON)
185 set (CPACK_PACKAGE_VERSION_MAJOR ${waffle_major_version})
186 set (CPACK_PACKAGE_VERSION_MINOR ${waffle_minor_version})
187 set (CPACK_PACKAGE_VERSION_PATCH ${waffle_patch_version})
189 # cpack detects win64 vs win32 only when msvc is available
190 # reported upstream, fix (likely post cmake 3.0) pending
192 if (CMAKE_SIZEOF_VOID_P EQUAL 8)
193 set (CPACK_SYSTEM_NAME win64)
197 # See https://www.vtk.org/Wiki/CMake:CPackPackageGenerators
199 set (CPACK_GENERATOR "ZIP")
201 set (CPACK_GENERATOR "TBZ2")