From 4938ee08e8e64496e9d01e6326e77cb394f3a00f Mon Sep 17 00:00:00 2001 From: James McCoy Date: Fri, 15 Jun 2018 00:00:08 -0400 Subject: cmake: Check for GNU compiler, not Linux, to set -D_GNU_SOURCE The Debian hurd-i386 [build] failed (partly) due to -D_GNU_SOURCE not be defined: [215/286] /usr/bin/cc -DINCLUDE_GENERATED_DECLARATIONS -Iconfig -I../src -Isrc/nvim/auto -Iinclude -I/usr/include/luajit-2.1 -g -O2 -fdebug-prefix-map=/<>=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -DDISABLE_LOG -Wdate-time -D_FORTIFY_SOURCE=2 -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -O2 -g -DMIN_LOG_LEVEL=3 -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -Wno-array-bounds -MD -MT src/nvim/CMakeFiles/nvim.dir/os/pty_process_unix.c.o -MF src/nvim/CMakeFiles/nvim.dir/os/pty_process_unix.c.o.d -o src/nvim/CMakeFiles/nvim.dir/os/pty_process_unix.c.o -c ../src/nvim/os/pty_process_unix.c ../src/nvim/os/pty_process_unix.c: In function 'pty_process_tty_name': ../src/nvim/os/pty_process_unix.c:121:10: warning: implicit declaration of function 'ptsname'; did you mean 'ttyname'? [-Wimplicit-function-declaration] return ptsname(ptyproc->tty_fd); Hurd is obviously not Linux, but it is using a GNU compiler and glibc so it needs -D_GNU_SOURCE for the ptsname() definition to be visible. [build]: https://buildd.debian.org/status/fetch.php?pkg=neovim&arch=hurd-i386&ver=0.3.0-2&stamp=1528981349&raw=0 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2100c53ad2..65490e4b6a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -297,7 +297,7 @@ option(LOG_LIST_ACTIONS "Add list actions logging" OFF) add_definitions(-DINCLUDE_GENERATED_DECLARATIONS) -if(CMAKE_SYSTEM_NAME STREQUAL "Linux") +if(CMAKE_COMPILER_IS_GNUCXX) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined") -- cgit From 33952c48bc11d181ea5e5604df931b8e3f953e06 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Fri, 15 Jun 2018 08:33:07 -0400 Subject: cmake: Explicitly declare C as the project language There's a mix of CXX and C related variables being set/referenced in our CMake files. Since we only use C, use an explicit language list of "C" instead of the implicit "C CXX" and replace all uses of CXX variables with their C counterparts --- CMakeLists.txt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 65490e4b6a..c97987e93f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ # best practices (3.0+): https://gist.github.com/mbinna/c61dbb39bca0e4fb7d1f73b0d66a4fd1 cmake_minimum_required(VERSION 2.8.7) -project(nvim) +project(nvim C) if(POLICY CMP0059) cmake_policy(SET CMP0059 OLD) # Needed until cmake 2.8.12. #4389 @@ -47,9 +47,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") 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() if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Darwin") @@ -181,7 +178,6 @@ if(NOT HAS_ACCEPTABLE_FORTIFY) # -U in add_definitions doesn't end up in the correct spot, so we add it to # the flags variable instead. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FORTIFY_SOURCE_PREFIX}-U_FORTIFY_SOURCE ${_FORTIFY_SOURCE_PREFIX}-D_FORTIFY_SOURCE=1") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${_FORTIFY_SOURCE_PREFIX}-U_FORTIFY_SOURCE ${_FORTIFY_SOURCE_PREFIX}-D_FORTIFY_SOURCE=1") endif() # Remove --sort-common from linker flags, as this seems to cause bugs (see #2641, #3374). @@ -264,7 +260,7 @@ if(HAS_DIAG_COLOR_FLAG) add_definitions(-fdiagnostics-color=auto) endif() -if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") +if(CMAKE_C_COMPILER_ID STREQUAL "GNU") # 1. Array-bounds testing is broken in some GCC versions before 4.8.5. # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56273 # 2. But _Pragma("...ignored") is broken (unresolved) in GCC 5+: @@ -297,7 +293,7 @@ option(LOG_LIST_ACTIONS "Add list actions logging" OFF) add_definitions(-DINCLUDE_GENERATED_DECLARATIONS) -if(CMAKE_COMPILER_IS_GNUCXX) +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined") @@ -308,7 +304,7 @@ if(CMAKE_COMPILER_IS_GNUCXX) add_definitions(-D_GNU_SOURCE) endif() -if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_NAME STREQUAL "SunOS") +if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "SunOS") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined -lsocket") endif() -- cgit From 25435a4bad9378507b6ef759ae5b7fe92a129c8f Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sat, 16 Jun 2018 10:18:55 -0400 Subject: cmake: Consolidate enabling of "undefined symbol" errors --- CMakeLists.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c97987e93f..2d6610733b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -294,9 +294,13 @@ option(LOG_LIST_ACTIONS "Add list actions logging" OFF) add_definitions(-DINCLUDE_GENERATED_DECLARATIONS) if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") - set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined") + if(CMAKE_SYSTEM_NAME STREQUAL "SunOS") + set(NO_UNDEFINED "-Wl,--no-undefined -lsocket") + elseif(NOT CMAKE_SYSTEM_NAME STREQUAL "Darwin") + set(NO_UNDEFINED "-Wl,--no-undefined") + endif() + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${NO_UNDEFINED}") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${NO_UNDEFINED}") # For O_CLOEXEC, O_DIRECTORY, and O_NOFOLLOW flags on older systems # (pre POSIX.1-2008: glibc 2.11 and earlier). #4042 @@ -304,10 +308,6 @@ if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang") add_definitions(-D_GNU_SOURCE) endif() -if(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "SunOS") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined -lsocket") -endif() - if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SIZEOF_VOID_P EQUAL 8) # Required for luajit. set(CMAKE_EXE_LINKER_FLAGS -- cgit From 23c9e3ec1ee16eef79bfebc5dd59de712e354ceb Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sat, 16 Jun 2018 10:20:25 -0400 Subject: Raise minimum CMake version to 2.8.12 and remove compat code 2.8.12 is supported by our main CI targets and [repology] confirms that this is broadly supported. [repology]: https://repology.org/metapackage/cmake/information --- CMakeLists.txt | 34 +++++++++--------------------- src/nvim/CMakeLists.txt | 6 ------ third-party/CMakeLists.txt | 2 +- third-party/cmake/GettextCMakeLists.txt | 2 +- third-party/cmake/GperfCMakeLists.txt | 2 +- third-party/cmake/LibiconvCMakeLists.txt | 2 +- third-party/cmake/LibuvCMakeLists.txt | 2 +- third-party/cmake/Libvterm-tbl2inc_c.cmake | 2 +- third-party/cmake/LibvtermCMakeLists.txt | 2 +- third-party/cmake/UnibiliumCMakeLists.txt | 2 +- third-party/cmake/libtermkeyCMakeLists.txt | 2 +- 11 files changed, 19 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d6610733b..cc40755b4d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ # intro: https://codingnest.com/basic-cmake/ # best practices (3.0+): https://gist.github.com/mbinna/c61dbb39bca0e4fb7d1f73b0d66a4fd1 -cmake_minimum_required(VERSION 2.8.7) +cmake_minimum_required(VERSION 2.8.12) project(nvim C) if(POLICY CMP0059) @@ -569,31 +569,17 @@ if(BUSTED_PRG) message(WARNING "disabling unit tests: no Luajit FFI in ${LUA_PRG}") endif() - if(${CMAKE_VERSION} VERSION_LESS 2.8.12) - if(CMAKE_GENERATOR MATCHES "Visual Studio") - set(TEST_LIBNVIM_PATH ${CMAKE_BINARY_DIR}/lib/nvim-test.dll) - else() - get_target_property(TEST_LIBNVIM_PATH nvim-test LOCATION) - endif() - configure_file( - ${CMAKE_SOURCE_DIR}/test/config/paths.lua.in - ${CMAKE_BINARY_DIR}/test/config/paths.lua) + if(LUA_HAS_FFI) + set(TEST_LIBNVIM_PATH $) else() - # To avoid duplicating paths.lua.in while we still support CMake < 2.8.12, - # use configure_file() to add the generator expression and then generate - # the final file - if(LUA_HAS_FFI) - set(TEST_LIBNVIM_PATH $) - else() - set(TEST_LIBNVIM_PATH "") - endif() - configure_file( - ${CMAKE_SOURCE_DIR}/test/config/paths.lua.in - ${CMAKE_BINARY_DIR}/test/config/paths.lua.gen) - file(GENERATE - OUTPUT ${CMAKE_BINARY_DIR}/test/config/paths.lua - INPUT ${CMAKE_BINARY_DIR}/test/config/paths.lua.gen) + set(TEST_LIBNVIM_PATH "") endif() + configure_file( + ${CMAKE_SOURCE_DIR}/test/config/paths.lua.in + ${CMAKE_BINARY_DIR}/test/config/paths.lua.gen) + file(GENERATE + OUTPUT ${CMAKE_BINARY_DIR}/test/config/paths.lua + INPUT ${CMAKE_BINARY_DIR}/test/config/paths.lua.gen) add_custom_target(functionaltest COMMAND ${CMAKE_COMMAND} diff --git a/src/nvim/CMakeLists.txt b/src/nvim/CMakeLists.txt index bdedce8076..825ebc29cf 100644 --- a/src/nvim/CMakeLists.txt +++ b/src/nvim/CMakeLists.txt @@ -394,12 +394,6 @@ endif() set(NVIM_EXEC_LINK_LIBRARIES ${NVIM_LINK_LIBRARIES} ${LUA_PREFERRED_LIBRARIES}) -if(CMAKE_VERSION VERSION_LESS "2.8.8") - # Use include_directories() because INCLUDE_DIRECTORIES target property - # is not supported - include_directories(${LUA_PREFERRED_INCLUDE_DIRS}) -endif() - # Don't use jemalloc in the unit test library. if(JEMALLOC_FOUND) list(APPEND NVIM_EXEC_LINK_LIBRARIES ${JEMALLOC_LIBRARIES}) diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index 8aae8ea9e4..cf49a67f60 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -1,5 +1,5 @@ # This is not meant to be included by the top-level. -cmake_minimum_required (VERSION 2.8.7) +cmake_minimum_required (VERSION 2.8.12) project(NVIM_DEPS) # Needed for: check_c_compiler_flag() diff --git a/third-party/cmake/GettextCMakeLists.txt b/third-party/cmake/GettextCMakeLists.txt index 67ec0d113f..5a6253df3b 100644 --- a/third-party/cmake/GettextCMakeLists.txt +++ b/third-party/cmake/GettextCMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.7) +cmake_minimum_required(VERSION 2.8.12) project(gettext C) # Adds PREFIX to each item in LIST diff --git a/third-party/cmake/GperfCMakeLists.txt b/third-party/cmake/GperfCMakeLists.txt index 32837fc166..15ae305ba8 100644 --- a/third-party/cmake/GperfCMakeLists.txt +++ b/third-party/cmake/GperfCMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.7) +cmake_minimum_required(VERSION 2.8.12) project(gperf LANGUAGES C CXX) add_executable(gperf diff --git a/third-party/cmake/LibiconvCMakeLists.txt b/third-party/cmake/LibiconvCMakeLists.txt index d14b8529d4..8ad3cc9352 100644 --- a/third-party/cmake/LibiconvCMakeLists.txt +++ b/third-party/cmake/LibiconvCMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.7) +cmake_minimum_required(VERSION 2.8.12) project(libiconv C) include_directories( diff --git a/third-party/cmake/LibuvCMakeLists.txt b/third-party/cmake/LibuvCMakeLists.txt index 8b51a101c6..c9b7c56e7b 100644 --- a/third-party/cmake/LibuvCMakeLists.txt +++ b/third-party/cmake/LibuvCMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.7) +cmake_minimum_required(VERSION 2.8.12) project(libuv LANGUAGES C) file(GLOB UV_SOURCES_COMMON src/*.c) diff --git a/third-party/cmake/Libvterm-tbl2inc_c.cmake b/third-party/cmake/Libvterm-tbl2inc_c.cmake index b1ee0246f1..7a82f4248b 100644 --- a/third-party/cmake/Libvterm-tbl2inc_c.cmake +++ b/third-party/cmake/Libvterm-tbl2inc_c.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.7) +cmake_minimum_required(VERSION 2.8.12) set(HEX_ALPHABET "0123456789abcdef") diff --git a/third-party/cmake/LibvtermCMakeLists.txt b/third-party/cmake/LibvtermCMakeLists.txt index 27d0d11e9f..dad3ef62c2 100644 --- a/third-party/cmake/LibvtermCMakeLists.txt +++ b/third-party/cmake/LibvtermCMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.11) +cmake_minimum_required(VERSION 2.8.12) project(libvterm LANGUAGES C) include(GNUInstallDirs) diff --git a/third-party/cmake/UnibiliumCMakeLists.txt b/third-party/cmake/UnibiliumCMakeLists.txt index 49bc12c6b7..a96482bcbb 100644 --- a/third-party/cmake/UnibiliumCMakeLists.txt +++ b/third-party/cmake/UnibiliumCMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.7) +cmake_minimum_required(VERSION 2.8.12) project(unibilium LANGUAGES C) file(GLOB SRC_FILES ${PROJECT_SOURCE_DIR}/*.c) diff --git a/third-party/cmake/libtermkeyCMakeLists.txt b/third-party/cmake/libtermkeyCMakeLists.txt index cb57631c1c..c55da7929a 100644 --- a/third-party/cmake/libtermkeyCMakeLists.txt +++ b/third-party/cmake/libtermkeyCMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.7) +cmake_minimum_required(VERSION 2.8.12) project(libtermkey) add_definitions(-D _CRT_SECURE_NO_WARNINGS) -- cgit From 863a87d5f3b248f8a5911abed75c90e435a26b5d Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sat, 16 Jun 2018 10:56:02 -0400 Subject: cmake: Comply with new CMP0054 policy --- runtime/CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index 0ae7c231af..70e4ca2eec 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -21,17 +21,13 @@ add_custom_command(OUTPUT ${GENERATED_SYN_VIM} ${FUNCS_DATA} ) -if(POLICY CMP0054) - cmake_policy(SET CMP0054 OLD) -endif() - file(GLOB PACKAGES ${PROJECT_SOURCE_DIR}/runtime/pack/dist/opt/*) set(GENERATED_PACKAGE_TAGS) foreach(PACKAGE ${PACKAGES}) get_filename_component(PACKNAME ${PACKAGE} NAME) file(GLOB "${PACKNAME}_DOC_FILES" ${PACKAGE}/doc/*.txt) - if("${PACKNAME}_DOC_FILES") + if(${PACKNAME}_DOC_FILES) file(MAKE_DIRECTORY ${GENERATED_PACKAGE_DIR}/${PACKNAME}) add_custom_target("${PACKNAME}-tags" COMMAND ${CMAKE_COMMAND} -E copy_directory -- cgit From a26fd8a888c0e8ed27f003ce5948aa3d42fdb087 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sun, 17 Jun 2018 23:29:39 -0400 Subject: cmake: Prefer add_definitions() for setting preprocessor defines --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cc40755b4d..a697480fba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -353,7 +353,7 @@ main(void) } " MSGPACK_HAS_FLOAT32) if(MSGPACK_HAS_FLOAT32) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNVIM_MSGPACK_HAS_FLOAT32") + add_definitions(-DNVIM_MSGPACK_HAS_FLOAT32) endif() option(FEAT_TUI "Enable the Terminal UI" ON) @@ -374,7 +374,7 @@ if(FEAT_TUI) } " UNIBI_HAS_VAR_FROM) if(UNIBI_HAS_VAR_FROM) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNVIM_UNIBI_HAS_VAR_FROM") + add_definitions(-DNVIM_UNIBI_HAS_VAR_FROM) endif() find_package(LibTermkey REQUIRED) -- cgit