From dc9a7728c0e395af0e987f315551213245cd11d1 Mon Sep 17 00:00:00 2001 From: jpr89 <31327577+jpr89@users.noreply.github.com> Date: Tue, 19 Jan 2021 00:55:23 -0500 Subject: [PATCH] Fixing cmake developer warning (#274) Here is the warning currently being produced: CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.19/Modules/GNUInstallDirs.cmake:223 (message): Unable to determine default CMAKE_INSTALL_LIBDIR directory because no target architecture is known. Please enable at least one language before including GNUInstallDirs. Call Stack (most recent call first): I noted how I fixed the error. This is caused by GNUInstallDirs automatically executing code just by including it. I also added -Werror=dev to the CI to ensure this never happens again. Co-authored-by: Juan Ramos --- .travis.yml | 2 +- CMakeLists.txt | 3 +++ cmake/cxxopts.cmake | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 87c78a7..8d42327 100644 --- a/.travis.yml +++ b/.travis.yml @@ -61,7 +61,7 @@ matrix: - g++-5 sources: *sources script: > - cmake -DCXXOPTS_BUILD_TESTS=ON -DCMAKE_CXX_COMPILER=$COMPILER + cmake -Werror=dev -DCXXOPTS_BUILD_TESTS=ON -DCMAKE_CXX_COMPILER=$COMPILER -DCMAKE_CXX_FLAGS=$CXXFLAGS $UNICODE_OPTIONS $CMAKE_OPTIONS . && make && make ARGS=--output-on-failure test diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e5043d..7db33e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,9 @@ project(cxxopts LANGUAGES CXX ) +# Must include after the project call due to GNUInstallDirs requiring a language be enabled (IE. CXX) +include(GNUInstallDirs) + # Determine whether this is a standalone project or included by other projects set(CXXOPTS_STANDALONE_PROJECT OFF) if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) diff --git a/cmake/cxxopts.cmake b/cmake/cxxopts.cmake index 9ef6caa..ef975b8 100644 --- a/cmake/cxxopts.cmake +++ b/cmake/cxxopts.cmake @@ -22,7 +22,6 @@ if (CMAKE_VERSION VERSION_GREATER 3.10 OR CMAKE_VERSION VERSION_EQUAL 3.10) include_guard() endif() -include(GNUInstallDirs) include(CMakePackageConfigHelpers) function(cxxopts_getversion version_arg)