Nice, thank you very much! This solves my problem. On Thu, Jan 21, 2016 at 3:56 PM, Nicholas Braden <[email protected] > wrote:
> Ah, I ran into this quirk too - the issue is that you have the quotes > incorrect: > > -DCMAKE_CXX_FLAGS="-march=native" > > Should be like this instead: > > "-DCMAKE_CXX_FLAGS=-march=native" > > Try that and see if it helps, I am pretty sure I ran into the exact > same problem. > > On Thu, Jan 21, 2016 at 8:27 AM, fkillus <[email protected]> wrote: > > Thanks for clarifying that external projects are not aware of the project > > they are embedded in. > > The CMAKE_COMPILER_IS_GNUCXX variable should be set automatically by > CMake > > as far > > as I understand it (see https://cmake.org/Wiki/CMake_Useful_Variables). > > > > I narrowed down the problem by creating a minimal setup which still > > reproduces the issue. > > In this case the super project is simply a wrapper around an external > dummy > > project. > > > > external/CMakeLists.txt: > > > > cmake_minimum_required( VERSION 3.4 ) > > project( external ) > > message( "External - CMAKE_COMPILER_IS_GNUCXX: " > > ${CMAKE_COMPILER_IS_GNUCXX} ) > > message( "External - CMAKE_CXX_COMPILER_ID: " ${CMAKE_CXX_COMPILER_ID} > ) > > message( "External - CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS} ) > > > > super/CMakeLists.txt: > > > > cmake_minimum_required( VERSION 3.4 ) > > project( super ) > > message( "Super - CMAKE_COMPILER_IS_GNUCXX: " > ${CMAKE_COMPILER_IS_GNUCXX} > > ) > > message( "Super - CMAKE_CXX_COMPILER_ID: " ${CMAKE_CXX_COMPILER_ID} ) > > message( "Super - CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS} ) > > include( ExternalProject ) > > ExternalProject_Add( > > external > > DOWNLOAD_COMMAND "" > > SOURCE_DIR ${CMAKE_SOURCE_DIR}/../external > > CMAKE_ARGS > > -DCMAKE_CXX_FLAGS="-march=native" > > INSTALL_COMMAND "" > > ) > > > > The problem occurs when the CMAKE_CXX_FLAGS variable is set inside the > > ExternalProject_Add > > command using quotes (i.e. "-march=native" in this example). The output > > obtained when configuring > > the super project with 'cmake ../super' is: > > > > -- The C compiler identification is GNU 5.2.0 > > -- The CXX compiler identification is GNU 5.2.0 > > -- Check for working C compiler: /usr/bin/cc > > -- Check for working C compiler: /usr/bin/cc -- works > > -- Detecting C compiler ABI info > > -- Detecting C compiler ABI info - done > > -- Detecting C compile features > > -- Detecting C compile features - done > > -- 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 > > Super - CMAKE_COMPILER_IS_GNUCXX: 1 > > Super - CMAKE_CXX_COMPILER_ID: GNU > > Super - CMAKE_CXX_FLAGS: > > -- Configuring done > > -- Generating done > > > > Afterwards building with 'make' results in: > > > > [ 12%] Creating directories for 'external' > > [ 25%] No download step for 'external' > > [ 37%] No patch step for 'external' > > [ 50%] No update step for 'external' > > [ 62%] Performing configure step for 'external' > > -- The C compiler identification is GNU 5.2.0 > > -- The CXX compiler identification is unknown > > -- Check for working C compiler: /usr/bin/cc > > -- Check for working C compiler: /usr/bin/cc -- works > > -- Detecting C compiler ABI info > > -- Detecting C compiler ABI info - done > > -- Detecting C compile features > > -- Detecting C compile features - done > > -- 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 > > External - CMAKE_COMPILER_IS_GNUCXX: > > External - CMAKE_CXX_COMPILER_ID: > > External - CMAKE_CXX_FLAGS: "-march=native" > > -- Configuring done > > -- Generating done > > > > This shows the compiler is not correctly identified for the external > > project. Directly configuring > > the external project with 'cmake -DCMAKE_CXX_FLAGS="-march=native" > > ../external' works though: > > > > -- The C compiler identification is GNU 5.2.0 > > -- The CXX compiler identification is GNU 5.2.0 > > -- Check for working C compiler: /usr/bin/cc > > -- Check for working C compiler: /usr/bin/cc -- works > > -- Detecting C compiler ABI info > > -- Detecting C compiler ABI info - done > > -- Detecting C compile features > > -- Detecting C compile features - done > > -- 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 > > External - CMAKE_COMPILER_IS_GNUCXX: 1 > > External - CMAKE_CXX_COMPILER_ID: GNU > > External - CMAKE_CXX_FLAGS: -march=native > > -- Configuring done > > -- Generating done > > > > > > It also works if the quotations marks in the super project listfile are > > removed. I.e. changing > > CMAKE_ARGS > > -DCMAKE_CXX_FLAGS="-march=native" > > to > > CMAKE_ARGS > > -DCMAKE_CXX_FLAGS=-march=native > > > > The question is now, is it still possible to add mutiple compile flags if > > one cannot use quotation marks? > > > > > > On Wed, Jan 20, 2016 at 6:58 PM, Nicholas Braden > > <[email protected]> wrote: > >> > >> Where/how is that variable normally set? External projects have no > >> awareness of the project they are in, they just run CMake as usual the > >> same way you would. If the variable is normally set by CMake itself, > >> make sure that your containing project and the external project both > >> find the same compiler. (They each do their own automatic search for > >> compilers) > >> > >> On Wed, Jan 20, 2016 at 11:41 AM, fkillus via CMake <[email protected]> > >> wrote: > >> > I have been trying to compile Ogre [1] as external dependency with > >> > ExternalProject_Add(). In theory this should be straightforward since > >> > Ogre > >> > itself also uses CMake as buildsystem. However, in the process I > >> > encountered > >> > the following problem: > >> > > >> > Ogre checks the value of the CMAKE_COMPILER_IS_GNUCXX variable in some > >> > places (e.g. [2]). I am running Linux and compiling with g++ and > >> > everything > >> > works fine if I manually configure Ogre with cmake or cmake-gui. > >> > Unfortunately, after wrapping everything inside ExternalProject_Add(), > >> > the > >> > CMAK_COMPILER_IS_GNUCXX variable is no longer being set correctly. > >> > > >> > A simple workaround is to manually set this variable, i.e.: > >> > > >> > ExternalProject_Add( > >> > ogre > >> > URL https://bitbucket.org/sinbad/ogre/get/v1-9-0.zip > >> > CMAKE_ARGS > >> > -DCMAKE_INSTALL_PREFIX=${DEPENDENCIES_OUTPUT_DIR} > >> > -DCMAKE_COMPILER_IS_GNUCXX=${CMAKE_COMPILER_IS_GNUCXX} # > >> > workaround > >> > ) > >> > > >> > This works, but I'm uncertain if this should be necessary. Is this a > bug > >> > or > >> > a feature? > >> > > >> > > >> > [1] https://bitbucket.org/sinbad/ogre > >> > [2] > >> > > >> > > https://bitbucket.org/sinbad/ogre/src/0d580c7216abe27fafe41cb43e31d8ed86ded591/CMake/Utils/OgreConfigTargets.cmake?at=default&fileviewer=file-view-default#OgreConfigTargets.cmake-277 > >> > > >> > -- > >> > > >> > 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 > > > > >
-- 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
