Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 1 | # |
| 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 |
| 25 | set(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 Grochowski | 1f6e380 | 2015-05-18 18:10:06 +0200 | [diff] [blame] | 29 | # are preferred over the already installed ones |
Pascal Bach | d5f87e1 | 2014-12-12 15:59:17 +0100 | [diff] [blame] | 30 | # since cmake 2.4.1 |
| 31 | set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON) |
| 32 | |
| 33 | # Use colored output |
| 34 | # since cmake 2.4.0 |
| 35 | set(CMAKE_COLOR_MAKEFILE ON) |
| 36 | |
| 37 | # Define the generic version of the libraries here |
| 38 | set(GENERIC_LIB_VERSION "0.1.0") |
| 39 | set(GENERIC_LIB_SOVERSION "0") |
| 40 | |
| 41 | # Set the default build type to release with debug info |
| 42 | if (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 | ) |
| 47 | endif (NOT CMAKE_BUILD_TYPE) |
| 48 | |
| 49 | # Create the compile command database for clang by default |
| 50 | set(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. |
| 56 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
| 57 | set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) |
| 58 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
Marco Molteni | aeb89aa | 2015-04-17 13:48:36 +0200 | [diff] [blame] | 59 | |
| 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. |
| 65 | set(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. |
| 70 | set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) |
James E. King, III | 43e959b | 2017-04-04 13:04:29 -0400 | [diff] [blame] | 71 | |
| 72 | # |
| 73 | # C++ Language Level Defaults |
| 74 | # |
| 75 | if (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") |
| 79 | endif() |
| 80 | |
| 81 | if (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 |
| 83 | endif() |
| 84 | |
| 85 | if (NOT DEFINED CMAKE_CXX_EXTENSIONS) |
| 86 | set(CMAKE_CXX_EXTENSIONS OFF) # use standards compliant language level for portability |
| 87 | endif() |