Commit dc9a7728c0e395af0e987f315551213245cd11d1

Authored by jpr89
Committed by GitHub
1 parent c55726ee

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 <juanr0911@gmail.com>
.travis.yml
... ... @@ -61,7 +61,7 @@ matrix:
61 61 - g++-5
62 62 sources: *sources
63 63 script: >
64   - cmake -DCXXOPTS_BUILD_TESTS=ON -DCMAKE_CXX_COMPILER=$COMPILER
  64 + cmake -Werror=dev -DCXXOPTS_BUILD_TESTS=ON -DCMAKE_CXX_COMPILER=$COMPILER
65 65 -DCMAKE_CXX_FLAGS=$CXXFLAGS $UNICODE_OPTIONS $CMAKE_OPTIONS .
66 66 && make && make ARGS=--output-on-failure test
67 67  
... ...
CMakeLists.txt
... ... @@ -30,6 +30,9 @@ project(cxxopts
30 30 LANGUAGES CXX
31 31 )
32 32  
  33 +# Must include after the project call due to GNUInstallDirs requiring a language be enabled (IE. CXX)
  34 +include(GNUInstallDirs)
  35 +
33 36 # Determine whether this is a standalone project or included by other projects
34 37 set(CXXOPTS_STANDALONE_PROJECT OFF)
35 38 if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
... ...
cmake/cxxopts.cmake
... ... @@ -22,7 +22,6 @@ if (CMAKE_VERSION VERSION_GREATER 3.10 OR CMAKE_VERSION VERSION_EQUAL 3.10)
22 22 include_guard()
23 23 endif()
24 24  
25   -include(GNUInstallDirs)
26 25 include(CMakePackageConfigHelpers)
27 26  
28 27 function(cxxopts_getversion version_arg)
... ...