core: use Wpointer-arith safe container_of
[mesa-waffle.git] / CMakeLists.txt
blobacece8675cb53fcd9965b000de0d3a8ab462251f
1 # Copyright 2012 Intel Corporation
3 # All rights reserved.
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.
26 project(waffle1 C CXX)
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)
49     include(WaffleCMocka)
50 endif()
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")
55 endif ()
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
75     DEPENDS check
76     )
78 find_program(VALGRIND_EXECUTABLE valgrind)
79 if(VALGRIND_EXECUTABLE)
80     # Runs the 'check' target under valgrind.
81     add_custom_target(valgrind-check
82         DEPENDS check
83         )
85     # Runs the 'check-func' target under valgrind.
86     add_custom_target(valgrind-check-func
87         DEPENDS valgrind-check check-func
88         )
89 endif()
91 # ------------------------------------------------------------------------------
92 # Add subdirectories
93 # ------------------------------------------------------------------------------
95 if(waffle_on_mac)
96     link_libraries(
97         ${COCOA_FRAMEWORK}
98         ${CORE_FOUNDATION_FRAMEWORK}
99         )
100 endif()
102 include_directories(
103     include
104     include/waffle-1
105     src
106     )
108 add_subdirectory(third_party/threads)
109 include_directories(
110     third_party/threads
111     )
112 set(THREADS_LIBRARIES threads_bundled)
114 if(MSVC)
115     add_subdirectory(third_party/getopt)
116     include_directories(
117         third_party/getopt
118         )
119     set(GETOPT_LIBRARIES getopt_bundled)
120 endif()
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)
129 endif()
131 if(waffle_build_examples)
132     add_subdirectory(examples)
133 endif()
135 # ------------------------------------------------------------------------------
136 # Install packaging files: waffle.pc WaffleConfigVersion.cmake, and
137 # WaffleConfig.cmake
138 # ------------------------------------------------------------------------------
140 configure_file(waffle.pc.in ${waffle_libname}.pc @ONLY)
142 install(
143     FILES ${CMAKE_BINARY_DIR}/${waffle_libname}.pc
144     DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
145     COMPONENT pkgconfig
146     )
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
164 install(
165     FILES
166         "${CMAKE_BINARY_DIR}/cmake/Modules/WaffleConfigVersion.cmake"
167         "${CMAKE_BINARY_DIR}/cmake/Modules/WaffleConfig.cmake"
168     DESTINATION "${ConfigPackageLocation}"
169     COMPONENT devel
172 # ------------------------------------------------------------------------------
173 # Install core documentation
174 # ------------------------------------------------------------------------------
176 install(
177     FILES
178         "README.md"
179         "LICENSE.txt"
180         "HACKING.txt"
181     DESTINATION "${CMAKE_INSTALL_DOCDIR}"
182     COMPONENT coredocs
183     )
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/")
194 endif()
196 install(
197     FILES "shell-completion/bash/wflinfo"
198     DESTINATION "${CMAKE_INSTALL_PREFIX}/${BASH_COMPLETION_COMPLETIONSDIR}"
199     COMPONENT shell-completion
200     )
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
213 if (MINGW)
214         if (CMAKE_SIZEOF_VOID_P EQUAL 8)
215                 set (CPACK_SYSTEM_NAME win64)
216         endif ()
217 endif ()
219 # See http://www.vtk.org/Wiki/CMake:CPackPackageGenerators
220 if (WIN32)
221         set (CPACK_GENERATOR "ZIP")
222 else ()
223         set (CPACK_GENERATOR "TBZ2")
224 endif ()
226 include(CPack)