blob: 7ae21362da1c44480093f803bd134ec21d7c5d8d [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
Pascal Bachd5f87e12014-12-12 15:59:17 +010037# Set the default build type to release with debug info
38if (NOT CMAKE_BUILD_TYPE)
39 set(CMAKE_BUILD_TYPE RelWithDebInfo
40 CACHE STRING
41 "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
42 )
43endif (NOT CMAKE_BUILD_TYPE)
44
45# Create the compile command database for clang by default
46set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
47
48# Put the libraries and binaries that get built into directories at the
49# top of the build tree rather than in hard-to-find leaf
50# directories. This simplifies manual testing and the use of the build
51# tree rather than installed thrift libraries.
52set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
53set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
54set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
Marco Molteniaeb89aa2015-04-17 13:48:36 +020055
56#
57# "rpath" support.
58# See http://www.itk.org/Wiki/index.php?title=CMake_RPATH_handling
59#
60# On MacOSX, for shared libraries, enable rpath support.
61set(CMAKE_MACOSX_RPATH TRUE)
62#
63# On any OS, for executables, allow linking with shared libraries in non-system
64# locations and running the executables without LD_PRELOAD or similar.
65# This requires the library to be built with rpath support.
66set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
James E. King, III43e959b2017-04-04 13:04:29 -040067
68#
James E. King, III82ae9572017-08-05 12:23:54 -040069# C++ Language Level Defaults - this depends on the compiler capabilities
James E. King, III43e959b2017-04-04 13:04:29 -040070#
71if (NOT DEFINED CMAKE_CXX_STANDARD)
cyy5e16f8b2019-01-06 10:49:20 +080072 set(CMAKE_CXX_STANDARD 11) # C++11
73 message(STATUS "Setting C++11 as the default language level.")
James E. King, III43e959b2017-04-04 13:04:29 -040074 message(STATUS "To specify a different C++ language level, set CMAKE_CXX_STANDARD")
75endif()
76
cyy5e16f8b2019-01-06 10:49:20 +080077if (CMAKE_CXX_STANDARD EQUAL 98)
78 message(FATAL_ERROR "only C++11 or above C++ standard is supported")
79elseif (CMAKE_CXX_STANDARD EQUAL 11)
80 # should not fallback to C++98
81 set(CMAKE_CXX_STANDARD_REQUIRED ON)
James E. King, III43e959b2017-04-04 13:04:29 -040082endif()
83
84if (NOT DEFINED CMAKE_CXX_EXTENSIONS)
85 set(CMAKE_CXX_EXTENSIONS OFF) # use standards compliant language level for portability
86endif()