<div dir="ltr">As well as moving the add_executable() call after you set the various CMAKE_CXX... variables, you should also replace the call to <span style="font-size:12.800000190734863px">add_compile_options(-std=c++</span><wbr style="font-size:12.800000190734863px"><span style="font-size:12.800000190734863px">11) with the following:</span><div><span style="font-size:12.800000190734863px"><br></span></div><div><span style="font-size:12.800000190734863px">set(CMAKE_CXX_EXTENSIONS OFF)</span><span style="font-size:12.800000190734863px"><br></span></div><div><span style="font-size:12.800000190734863px"><br></span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 11, 2017 at 3:11 PM, Michael Ellery <span dir="ltr"><<a href="mailto:mellery451@gmail.com" target="_blank">mellery451@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
> On Jul 10, 2017, at 10:07 PM, Florian Lindner <<a href="mailto:mailinglists@xgm.de">mailinglists@xgm.de</a>> wrote:<br>
><br>
> Hello,<br>
><br>
> my complete cmake file looks like that:<br>
><br>
> cmake_minimum_required (VERSION 3.1)<br>
> project(Preallocation)<br>
> add_executable(prealloc prealloc_parallel.cpp)<br>
><br>
> set(CMAKE_CXX_STANDARD 11)<br>
> set(CMAKE_CXX_STANDARD_<wbr>REQUIRED ON)<br>
> add_compile_options(-std=c++<wbr>11)<br>
><br>
> find_library(petsc petsc<br>
>  PATHS $ENV{PETSC_DIR}/$ENV{PETSC_<wbr>ARCH}/lib)<br>
> if(NOT petsc)<br>
>  message(FATAL_ERROR "petsc was not found")<br>
> endif()<br>
> target_link_libraries(prealloc ${petsc})<br>
><br>
> find_package(Boost 1.60.0<br>
>  REQUIRED<br>
>  COMPONENTS program_options)<br>
> target_link_libraries(prealloc ${Boost_LIBRARIES})<br>
><br>
> find_package(MPI<br>
>  REQUIRED)<br>
> target_link_libraries(prealloc ${MPI_LIBRARIES})<br>
><br>
> set(COMPILE_FLAGS  ${COMPILE_FLAGS} ${MPI_COMPILE_FLAGS})<br>
> set(LINK_FLAGS ${LINK_FLAGS} ${MPI_LINK_FLAGS})<br>
><br>
<br>
</span>I would try moving the add_executable() to the end of the CMakeLists file (after the set() and find_library calls…)<br>
<br>
-Mike<br>
<div class="HOEnZb"><div class="h5"><br>
--<br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/<wbr>CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/<wbr>training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/<wbr>opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/cmake" rel="noreferrer" target="_blank">http://public.kitware.com/<wbr>mailman/listinfo/cmake</a></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Craig Scott<br><div>Melbourne, Australia</div><div><a href="https://crascit.com" target="_blank">https://crascit.com</a><br></div></div></div></div></div></div></div>
</div>