From 29b99a11a45bb8d84e18dd38c89e477202b3ece1 Mon Sep 17 00:00:00 2001 From: Florian Apolloner Date: Wed, 30 Aug 2017 14:17:54 +0200 Subject: [PATCH] Specify CXX as project language for CMake >= 3.4 (#1027) --- CMakeLists.txt | 7 ++++++- tests/CMakeLists.txt | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cad29a9c..2a3e1ed7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,12 @@ if (POLICY CMP0048) cmake_policy(SET CMP0048 NEW) endif() -project(pybind11) +# 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) +else() + project(pybind11 CXX) +endif() # Check if pybind11 is being used directly or via add_subdirectory set(PYBIND11_MASTER_PROJECT OFF) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index df77d430..52326297 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -12,7 +12,7 @@ option(PYBIND11_WERROR "Report all warnings as errors" OFF) if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) # 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 - project(pybind11_tests) + project(pybind11_tests CXX) find_package(pybind11 REQUIRED CONFIG) endif()