[CMake] Can not get C++ 11 support enabled
Craig Scott
craig.scott at crascit.com
Tue Jul 11 01:21:35 EDT 2017
As well as moving the add_executable() call after you set the various
CMAKE_CXX... variables, you should also replace the call to
add_compile_options(-std=c++11) with the following:
set(CMAKE_CXX_EXTENSIONS OFF)
On Tue, Jul 11, 2017 at 3:11 PM, Michael Ellery <mellery451 at gmail.com>
wrote:
>
> > On Jul 10, 2017, at 10:07 PM, Florian Lindner <mailinglists at xgm.de>
> wrote:
> >
> > Hello,
> >
> > my complete cmake file looks like that:
> >
> > cmake_minimum_required (VERSION 3.1)
> > project(Preallocation)
> > add_executable(prealloc prealloc_parallel.cpp)
> >
> > set(CMAKE_CXX_STANDARD 11)
> > set(CMAKE_CXX_STANDARD_REQUIRED ON)
> > add_compile_options(-std=c++11)
> >
> > find_library(petsc petsc
> > PATHS $ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/lib)
> > if(NOT petsc)
> > message(FATAL_ERROR "petsc was not found")
> > endif()
> > target_link_libraries(prealloc ${petsc})
> >
> > find_package(Boost 1.60.0
> > REQUIRED
> > COMPONENTS program_options)
> > target_link_libraries(prealloc ${Boost_LIBRARIES})
> >
> > find_package(MPI
> > REQUIRED)
> > target_link_libraries(prealloc ${MPI_LIBRARIES})
> >
> > set(COMPILE_FLAGS ${COMPILE_FLAGS} ${MPI_COMPILE_FLAGS})
> > set(LINK_FLAGS ${LINK_FLAGS} ${MPI_LINK_FLAGS})
> >
>
> I would try moving the add_executable() to the end of the CMakeLists file
> (after the set() and find_library calls…)
>
> -Mike
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake
>
--
Craig Scott
Melbourne, Australia
https://crascit.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170711/01c03686/attachment.html>
More information about the CMake
mailing list