[CMake] Can not get C++ 11 support enabled
Michael Ellery
mellery451 at gmail.com
Tue Jul 11 01:11:59 EDT 2017
> 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
More information about the CMake
mailing list