diff options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 67 |
1 files changed, 53 insertions, 14 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index d67aebee64..223c28f348 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,37 @@ set(DEPS_BIN_DIR "${DEPS_INSTALL_DIR}/bin") list(APPEND CMAKE_PREFIX_PATH ${DEPS_INSTALL_DIR}) +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + # CMake tries to treat /sw and /opt/local as extension of the system path, but + # that doesn't really work out very well. Once you have a dependency that + # resides there and have to add it as an include directory, then any other + # dependency that could be satisfied from there must be--otherwise you can end + # up with conflicting versions. So, let's make them more of a priority having + # them be included as one of the first places to look for dependencies. + list(APPEND CMAKE_PREFIX_PATH /sw /opt/local) + + # Work around some old, broken detection by CMake for knowing when to use the + # isystem flag. Apple's compilers have supported this for quite some time + # now. + if(CMAKE_COMPILER_IS_GNUCC) + set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-isystem ") + endif() + if(CMAKE_COMPILER_IS_GNUCXX) + set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ") + endif() +endif() + +# Set available build types for CMake GUIs. +# A different build type can still be set by -DCMAKE_BUILD_TYPE=... +set_property(CACHE CMAKE_BUILD_TYPE PROPERTY + STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo") + +# Set default build type. +if(NOT CMAKE_BUILD_TYPE) + message(STATUS "CMAKE_BUILD_TYPE not given; setting to 'RelWithDebInfo'.") + set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build." FORCE) +endif() + # Version tokens include(GetGitRevisionDescription) get_git_head_revision(GIT_REFSPEC NVIM_VERSION_COMMIT) @@ -28,20 +59,11 @@ git_timestamp(GIT_TIMESTAMP) if(GIT_TIMESTAMP) set(NVIM_VERSION_BUILD "+${GIT_TIMESTAMP}") endif() +set(NVIM_VERSION_BUILD_TYPE "${CMAKE_BUILD_TYPE}") +# NVIM_VERSION_CFLAGS set further below. set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -# Work around some old, broken detection by CMake for knowing when to use the -# isystem flag. Apple's compilers have supported this for quite some time now. -if(APPLE) - if(CMAKE_COMPILER_IS_GNUCC) - set(CMAKE_INCLUDE_SYSTEM_FLAG_C "-isystem ") - endif() - if(CMAKE_COMPILER_IS_GNUCXX) - set(CMAKE_INCLUDE_SYSTEM_FLAG_CXX "-isystem ") - endif() -endif() - # Default to -O2 on release builds. string(REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") @@ -67,9 +89,16 @@ if(TRAVIS_CI_BUILD) add_definitions(-Werror) endif() +if(CMAKE_COMPILER_IS_GNUCC) + include(CheckCCompilerFlag) + check_c_compiler_flag(-Og HAS_OG_FLAG) +else() + set(HAS_OG_FLAG 0) +endif() + # Set custom build flags for RelWithDebInfo. # -DNDEBUG purposely omitted because we want assertions. -if(CMAKE_COMPILER_IS_GNUCC) +if(HAS_OG_FLAG) set(CMAKE_C_FLAGS_RELWITHDEBINFO "-Og -g" CACHE STRING "Flags used by the compiler during release builds with debug info." FORCE) else() @@ -128,7 +157,12 @@ include_directories(SYSTEM ${LUAJIT_INCLUDE_DIRS}) find_package(LibIntl) if(LibIntl_FOUND) - include_directories(SYSTEM ${LibIntl_INCLUDE_DIR}) + include_directories(SYSTEM ${LibIntl_INCLUDE_DIRS}) +endif() + +find_package(Iconv) +if(Iconv_FOUND) + include_directories(SYSTEM ${Iconv_INCLUDE_DIRS}) endif() # Determine platform's threading library. Set CMAKE_THREAD_PREFER_PTHREAD @@ -228,9 +262,14 @@ install(SCRIPT ${CMAKE_MODULE_PATH}/GenerateHelptags.cmake) # Go down the tree. -add_subdirectory(config) add_subdirectory(src/nvim) +# Read compilation flags from src/nvim, +# used in config subdirectory below. +include(GetCompileFlags) +get_compile_flags(NVIM_VERSION_CFLAGS) + add_subdirectory(test/includes) +add_subdirectory(config) # Setup some test-related bits. We do this after going down the tree because we # need some of the targets. |