Specify CXX as project language for CMake >= 3.4 (#1027)

This commit is contained in:
Florian Apolloner 2017-08-30 14:17:54 +02:00 committed by Dean Moldovan
parent b8c5dbdef5
commit 29b99a11a4
2 changed files with 7 additions and 2 deletions

View File

@ -12,7 +12,12 @@ if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW) cmake_policy(SET CMP0048 NEW)
endif() endif()
# CMake versions < 3.4.0 do not support try_compile/pthread checks without C as active language.
if(CMAKE_VERSION VERSION_LESS 3.4.0)
project(pybind11) project(pybind11)
else()
project(pybind11 CXX)
endif()
# Check if pybind11 is being used directly or via add_subdirectory # Check if pybind11 is being used directly or via add_subdirectory
set(PYBIND11_MASTER_PROJECT OFF) set(PYBIND11_MASTER_PROJECT OFF)

View File

@ -12,7 +12,7 @@ option(PYBIND11_WERROR "Report all warnings as errors" OFF)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
# We're being loaded directly, i.e. not via add_subdirectory, so make this # We're being loaded directly, i.e. not via add_subdirectory, so make this
# work as its own project and load the pybind11Config to get the tools we need # work as its own project and load the pybind11Config to get the tools we need
project(pybind11_tests) project(pybind11_tests CXX)
find_package(pybind11 REQUIRED CONFIG) find_package(pybind11 REQUIRED CONFIG)
endif() endif()