mardi 27 février 2018

C++11 activation with

I'm using a Python library, named PyPHS, specialized in physical modeling. To save computation during the simulation, it implements a C++ code generation feature. It uses CMake to generate an executable of a particular simulation.

It is implemented in C++ 11.


Issue

In the CMakeLists.txt file, the C++ 11 feature is activated by the following line:

target_compile_features(<project_name> PUBLIC cxx_std_11)

On my computer (CMake 3.5.1 & Ubuntu 16.04.4 Xenial Xerus), CMake throws an error: this feature is unknown:

-- The CXX compiler identification is GNU 5.4.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:31 (target_compile_features):
  target_compile_features specified unknown feature "cxx_std_11" for target
  "dampedosc".
```

-- Configuring incomplete, errors occurred!
See also "/home/victorw/git/vocal-phs/python/output/dampedosc/CMakeFiles/CMakeOutput.log".

This error has not been encountered on other installs (Debian 8, Mac OSX or windows 7)

Fix

I’ve changed the CMakeLists.txt template. Here is the link to the commit, on my own fork of PyPHS.

I’ve replaced the target_compile_features(<project_name> PUBLIC cxx_std_11) by set (CMAKE_CXX_STANDARD 11)


Question

What is the difference between the two commands? What are your insights on this matter? Did I forget to mention some information?

Thank you for your answers!

Aucun commentaire:

Enregistrer un commentaire