When building I set the compiler with the -DCMAKE_<LANG>_COMPILER=<path> option. Some tests generate new projects with CMake but don't make use of the compiler that I want CMake to use. I suspect that this isn't an issue for people who use the CC/CXX enviroment variables (or any equivalent on non-Linux systems).
Steps to reproduce:
- Have a Linux environment that by default only has an unsupported compiler. I use CentOS6, which has GCC 4.4.7 by default.
- Install a compiler toolchain in a non-PATH location. I use the devtoolset-8 package from the SCLo RPM stream which provides a GCC 8.2.1 based toolchain located at /opt/rh/devtoolset-8/root/usr/bin/{gcc,g++}
- Download the source code and try to build it, setting the C++ and C compilers with
-DCMAKE_CXX_COMPILER=<path to g++> and -DCMAKE_C_COMPILER=<path to gcc>
- Compile project
- Run test with CTest. The tests that create new CMake projects should fail because they will pick up the system GCC (4.4.7).
A patch I made and tried on my Cent6 environment:
diff --git a/test/cmake_add_subdirectory/CMakeLists.txt b/test/cmake_add_subdirectory/CMakeLists.txt
index ad04547e7d1c3943781a7e119c7372eaf74a1274..6126033de59ab0b2d0b683ec7485c8932a07c94c 100644
--- a/test/cmake_add_subdirectory/CMakeLists.txt
+++ b/test/cmake_add_subdirectory/CMakeLists.txt
@@ -3,6 +3,8 @@ add_test(NAME cmake_add_subdirectory_configure
-G "${CMAKE_GENERATOR}"
-Dnlohmann_json_source=${PROJECT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/project
+ -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
+ -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
)
add_test(NAME cmake_add_subdirectory_build
COMMAND ${CMAKE_COMMAND} --build .
diff --git a/test/cmake_import/CMakeLists.txt b/test/cmake_import/CMakeLists.txt
index 911c342c6ded16a057d16480e9a7c05eafb0cd23..ec660378cdfccbbc8a79f9b02df1ad09e529f2b4 100644
--- a/test/cmake_import/CMakeLists.txt
+++ b/test/cmake_import/CMakeLists.txt
@@ -3,6 +3,8 @@ add_test(NAME cmake_import_configure
-G "${CMAKE_GENERATOR}"
-Dnlohmann_json_DIR=${PROJECT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/project
+ -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
+ -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
)
add_test(NAME cmake_import_build
COMMAND ${CMAKE_COMMAND} --build .
diff --git a/test/cmake_import_minver/CMakeLists.txt b/test/cmake_import_minver/CMakeLists.txt
index 8cef2fabb4c29198bf6791a0f86dc1a11cf6d7f8..eb7e6906d513dd3ba868d6ffb1d8aa294959bc6a 100644
--- a/test/cmake_import_minver/CMakeLists.txt
+++ b/test/cmake_import_minver/CMakeLists.txt
@@ -3,6 +3,8 @@ add_test(NAME cmake_import_minver_configure
-G "${CMAKE_GENERATOR}"
-Dnlohmann_json_DIR=${PROJECT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/project
+ -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
+ -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
)
add_test(NAME cmake_import_minver_build
COMMAND ${CMAKE_COMMAND} --build .
I get unrelated failures referencing "issue #186 miloyip/nativejson-benchmark: floating-point parsing" but I will explore those in a separate issue if appropriate.
When building I set the compiler with the
-DCMAKE_<LANG>_COMPILER=<path>option. Some tests generate new projects with CMake but don't make use of the compiler that I want CMake to use. I suspect that this isn't an issue for people who use the CC/CXX enviroment variables (or any equivalent on non-Linux systems).Steps to reproduce:
-DCMAKE_CXX_COMPILER=<path to g++>and-DCMAKE_C_COMPILER=<path to gcc>A patch I made and tried on my Cent6 environment:
I get unrelated failures referencing "issue #186 miloyip/nativejson-benchmark: floating-point parsing" but I will explore those in a separate issue if appropriate.