| Bug #91140 | CHECK_CXX_SOURCE_COMPILES Fails All Conditions | ||
|---|---|---|---|
| Submitted: | 5 Jun 2018 0:38 | Modified: | 5 Jun 2018 10:20 |
| Reporter: | Rebeka Fox | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | Connector / C++ | Severity: | S1 (Critical) |
| Version: | Connector/C++ 8.0.11 | OS: | Windows (x64 CMAKE Source) |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | c++ connector, cmake, community | ||
[5 Jun 2018 8:41]
MySQL Verification Team
********************************************************************** ** Visual Studio 2017 Developer Command Prompt v15.6.1 ** Copyright (c) 2017 Microsoft Corporation ********************************************************************** [vcvarsall.bat] Environment initialized for: 'x64' C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional>cd\ C:\>cd tmp C:\tmp>cd "mysql-connector-c++-8.0.11-src" C:\tmp\mysql-connector-c++-8.0.11-src>cmake ./ > cmake-output.txt Building on system: Windows-10.0.16299 (AMD64) Using cmake generator: Visual Studio 15 2017 Using 32bit genereator Building version 8.0.11 Building shared connector library Configuring CDK as part of MySQL_CONCPP project WITH_TESTS: OFF CDK include path: C:/tmp/mysql-connector-c++-8.0.11-src/cdk/include;C:/tmp/mysql-connector-c++-8.0.11-src/cdk/include WITH_SSL: Configuring Protobuf build using cmake generator: Visual Studio 15 2017 - setting generic location to: C:/tmp/mysql-connector-c++-8.0.11-src/cdk/protobuf/$(Configuration)/protobuf.lib - setting generic location to: C:/tmp/mysql-connector-c++-8.0.11-src/cdk/protobuf/$(Configuration)/protobuf-lite.lib Protobuf include path: C:/tmp/mysql-connector-c++-8.0.11-src/cdk/protobuf/protobuf-2.6.1/src Merging static libraries into cdk: - protobuf-lite Wrote configuration header: C:/tmp/mysql-connector-c++-8.0.11-src/cdk/include/mysql/cdk/config.h Connector library name: mysqlcppconn8-1-vs14 Install location: C:/Users/gsolorza/MySQL/MySQL Connector C++ 8.0 Connector libraries will be installed at: lib C:\tmp\mysql-connector-c++-8.0.11-src>
[5 Jun 2018 8:42]
MySQL Verification Team
cmake output
Attachment: cmake-output.txt (text/plain), 3.28 KiB.
[5 Jun 2018 8:43]
MySQL Verification Team
Thank you for the bug report. 14>try.vcxproj -> C:\tmp\mysql-connector-c++-8.0.11-src\Debug\try.exe 14>Done building project "try.vcxproj". 15>------ Rebuild All started: Project: ALL_BUILD, Configuration: Debug Win32 ------ 15>Building Custom Rule C:/tmp/mysql-connector-c++-8.0.11-src/CMakeLists.txt 15>CMake does not need to re-run because C:/tmp/mysql-connector-c++-8.0.11-src/CMakeFiles/generate.stamp is up-to-date. ========== Rebuild All: 15 succeeded, 0 failed, 0 skipped ==========
[5 Jun 2018 10:20]
Rebeka Fox
there are a few other errors, but it mostly compiles with a dowloaded copy of cmake, using vc compilers. it can't find a couple headers. i'm sure i can figure that out. it simply will not compile inside of visual studio.
[7 Jun 2018 12:27]
Tor Didriksen
The test code is syntactically wrong, this will pass for Visual Studio:
CHECK_CXX_SOURCE_COMPILES(
"#include <memory>
void test(std::shared_ptr<int>) {};
int main() {return 0;}"
HAVE_SHARED_PTR
)
However, the test is semantically dubious as well: it sets CMAKE_REQUIRED_FLAGS to -std=c++11, and then tests for std::shared_ptr. Are there *any* C++ compilers which claim to support C++11 which *do not* support shared_ptr?
BTW: AFAIK Visual Studio does not support -std=Cxx anyways, so I recommend simply testing for compiler version: MSVC_VERSION >= 1900 supports C++11

Description: When building the community c++ connector in visual studio 2017 using cmake, CHECK_CXX_SOURCE_COMPILES fails. it fails even if only int main(){ return 0; } is used. It fails for each use in .\cdk\foundation\CMakeLists.txt starting with std::shared_ptr<T>. include(CheckCXXSourceCompiles) set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -std=c++11") CHECK_CXX_SOURCE_COMPILES( "#include <memory> void test(std::shared_ptr) {}; int main() {return 0};" HAVE_SHARED_PTR ) ADD_CONFIG(HAVE_SHARED_PTR) if (NOT HAVE_SHARED_PTR) message(FATAL_ERROR "Type std::shared_ptr required by CDK is not available") endif() How to repeat: unzip folder. open using the visual studio cmake open folder. let it compile. fails.