1 # Copyright 2012 Intel Corporation
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are met:
8 # - Redistributions of source code must retain the above copyright notice, this
9 # list of conditions and the following disclaimer.
11 # - Redistributions in binary form must reproduce the above copyright notice,
12 # this list of conditions and the following disclaimer in the documentation
13 # and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
19 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 cmake_minimum_required(VERSION 2.8.12)
30 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
32 # Set the default location for all build artifacts to traditionally named
33 # top-level directories. CMake's default location for build artifacts varies
34 # per artifact and is hard-to-guess.
35 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
36 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
37 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
39 include(WaffleDefineOS)
40 include(WaffleFindDependencies)
41 include(Options.cmake)
42 include(WaffleDefineInternalOptions)
43 include(WaffleValidateOptions)
44 include(WaffleDefineVersion)
45 include(WaffleDefineCompilerFlags)
46 include(GNUInstallDirs)
48 if(waffle_build_tests)
52 # Require MSVC 2013 U4
53 if (MSVC AND ${CMAKE_C_COMPILER_VERSION} VERSION_LESS 18.00.31101.0)
54 message (FATAL_ERROR "Visual Studio 2013 Update 4 or later required")
57 find_package(PkgConfig)
59 # ------------------------------------------------------------------------------
60 # Targets: check, check-func, valgrind-check, valgrind-check-func
61 # ------------------------------------------------------------------------------
64 # Target 'check' runs unit tests, but no functional tests.
66 add_custom_target(check)
69 # Target 'check-func' runs functional tests as well as unit tests.
71 # The unit tests are ran first (due to the depenency on 'check'). If any unit
72 # test fails, then no functional tests run.
74 add_custom_target(check-func
78 find_program(VALGRIND_EXECUTABLE valgrind)
79 if(VALGRIND_EXECUTABLE)
80 # Runs the 'check' target under valgrind.
81 add_custom_target(valgrind-check
85 # Runs the 'check-func' target under valgrind.
86 add_custom_target(valgrind-check-func
87 DEPENDS valgrind-check check-func
91 # ------------------------------------------------------------------------------
93 # ------------------------------------------------------------------------------
98 ${CORE_FOUNDATION_FRAMEWORK}
108 add_subdirectory(third_party/threads)
112 set(THREADS_LIBRARIES threads_bundled)
115 add_subdirectory(third_party/getopt)
119 set(GETOPT_LIBRARIES getopt_bundled)
122 add_subdirectory(doc)
123 add_subdirectory(src)
124 add_subdirectory(include)
125 add_subdirectory(man)
127 if(waffle_build_tests)
128 add_subdirectory(tests)
131 if(waffle_build_examples)
132 add_subdirectory(examples)
135 # ------------------------------------------------------------------------------
136 # Install packaging files: waffle.pc WaffleConfigVersion.cmake, and
138 # ------------------------------------------------------------------------------
140 configure_file(waffle.pc.in ${waffle_libname}.pc @ONLY)
143 FILES ${CMAKE_BINARY_DIR}/${waffle_libname}.pc
144 DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
148 set(ConfigPackageLocation "${CMAKE_INSTALL_LIBDIR}/cmake/Waffle")
149 include(CMakePackageConfigHelpers)
150 write_basic_package_version_file(
151 "${CMAKE_BINARY_DIR}/cmake/Modules/WaffleConfigVersion.cmake"
152 VERSION "${waffle_version}"
153 COMPATIBILITY SameMajorVersion
156 configure_package_config_file(
157 cmake/Modules/WaffleConfig.cmake.in
158 cmake/Modules/WaffleConfig.cmake
159 INSTALL_DESTINATION "${ConfigPackageLocation}"
160 PATH_VARS CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_INCLUDEDIR
161 NO_CHECK_REQUIRED_COMPONENTS_MACRO
166 "${CMAKE_BINARY_DIR}/cmake/Modules/WaffleConfigVersion.cmake"
167 "${CMAKE_BINARY_DIR}/cmake/Modules/WaffleConfig.cmake"
168 DESTINATION "${ConfigPackageLocation}"
172 # ------------------------------------------------------------------------------
173 # Install core documentation
174 # ------------------------------------------------------------------------------
181 DESTINATION "${CMAKE_INSTALL_DOCDIR}"
185 # ------------------------------------------------------------------------------
186 # Install shell completion
187 # ------------------------------------------------------------------------------
189 find_package(bash-completion)
190 if (NOT BASH_COMPLETION_FOUND)
191 # Fallback default dir
192 set(BASH_COMPLETION_COMPLETIONSDIR
193 "${CMAKE_INSTALL_DATADIR}/bash-completion/completions/")
197 FILES "shell-completion/bash/wflinfo"
198 DESTINATION "${CMAKE_INSTALL_PREFIX}/${BASH_COMPLETION_COMPLETIONSDIR}"
199 COMPONENT shell-completion
202 # ------------------------------------------------------------------------------
204 include(WafflePrintConfigurationSummary)
206 set (CPACK_SET_DESTDIR ON)
207 set (CPACK_PACKAGE_VERSION_MAJOR ${waffle_major_version})
208 set (CPACK_PACKAGE_VERSION_MINOR ${waffle_minor_version})
209 set (CPACK_PACKAGE_VERSION_PATCH ${waffle_patch_version})
211 # cpack detects win64 vs win32 only when msvc is available
212 # reported upstream, fix (likely post cmake 3.0) pending
214 if (CMAKE_SIZEOF_VOID_P EQUAL 8)
215 set (CPACK_SYSTEM_NAME win64)
219 # See https://www.vtk.org/Wiki/CMake:CPackPackageGenerators
221 set (CPACK_GENERATOR "ZIP")
223 set (CPACK_GENERATOR "TBZ2")