blob: 365c0a43452a15053c86a97e897bd1af7a241e0d [file] [log] [blame]
Pascal Bachd5f87e12014-12-12 15:59:17 +01001#
2# Licensed to the Apache Software Foundation (ASF) under one
3# or more contributor license agreements. See the NOTICE file
4# distributed with this work for additional information
5# regarding copyright ownership. The ASF licenses this file
6# to you under the Apache License, Version 2.0 (the
7# "License"); you may not use this file except in compliance
8# with the License. You may obtain a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing,
13# software distributed under the License is distributed on an
14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15# KIND, either express or implied. See the License for the
16# specific language governing permissions and limitations
17# under the License.
18#
19
20
21# Always include srcdir and builddir in include path
22# This saves typing ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY} in
23# about every subdir
24# since cmake 2.4.0
25set(CMAKE_INCLUDE_CURRENT_DIR ON)
26
27# Put the include dirs which are in the source or build tree
28# before all other include dirs, so the headers in the sources
Konrad Grochowski1f6e3802015-05-18 18:10:06 +020029# are preferred over the already installed ones
Pascal Bachd5f87e12014-12-12 15:59:17 +010030# since cmake 2.4.1
31set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
32
33# Use colored output
34# since cmake 2.4.0
35set(CMAKE_COLOR_MAKEFILE ON)
36
37# Define the generic version of the libraries here
38set(GENERIC_LIB_VERSION "0.1.0")
39set(GENERIC_LIB_SOVERSION "0")
40
41# Set the default build type to release with debug info
42if (NOT CMAKE_BUILD_TYPE)
43 set(CMAKE_BUILD_TYPE RelWithDebInfo
44 CACHE STRING
45 "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
46 )
47endif (NOT CMAKE_BUILD_TYPE)
48
49# Create the compile command database for clang by default
50set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
51
52# Put the libraries and binaries that get built into directories at the
53# top of the build tree rather than in hard-to-find leaf
54# directories. This simplifies manual testing and the use of the build
55# tree rather than installed thrift libraries.
56set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
57set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
58set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
Marco Molteniaeb89aa2015-04-17 13:48:36 +020059
60#
61# "rpath" support.
62# See http://www.itk.org/Wiki/index.php?title=CMake_RPATH_handling
63#
64# On MacOSX, for shared libraries, enable rpath support.
65set(CMAKE_MACOSX_RPATH TRUE)
66#
67# On any OS, for executables, allow linking with shared libraries in non-system
68# locations and running the executables without LD_PRELOAD or similar.
69# This requires the library to be built with rpath support.
70set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
James E. King, III43e959b2017-04-04 13:04:29 -040071
72#
73# C++ Language Level Defaults
74#
75if (NOT DEFINED CMAKE_CXX_STANDARD)
76 set(CMAKE_CXX_STANDARD 11) # C++11
77 message(STATUS "Setting C++11 as the default language level.")
78 message(STATUS "To specify a different C++ language level, set CMAKE_CXX_STANDARD")
79endif()
80
81if (NOT DEFINED CMAKE_CXX_STANDARD_REQUIRED)
82 set(CMAKE_CXX_STANDARD_REQUIRED OFF) # can degrade to C++98 if compiler does not support C++11
83endif()
84
85if (NOT DEFINED CMAKE_CXX_EXTENSIONS)
86 set(CMAKE_CXX_EXTENSIONS OFF) # use standards compliant language level for portability
87endif()