I've used ExternalProject_Add to trick CMake into supporting two
compilers to build my project.

Part of my project needs OpenMP, but other parts do not.  So, on
MacOS, I would prefer to build most of the project with CLang, but the
OpenMP requiring part with gcc.

I have CMake set up to detect whether the compiler supports OpenMP.
If it does not, it checks for a user-supplied alternate compiler.

If the user has supplied an alternate compiler, CMake treats the
current directory as an ExternalProject , but passes the alternate
OpenMP capable compiler.

In general, this works well.  However, this arrangement does not
notice when the source files have changed and cause the External
Project to rebuild.

I'm using ExternalProject_ForceBuild to try to make the EP build every
time -- that works, but once inside the EP, make doesn't recognize
that the source files have been updated.

The meat of the situation is something like this....

ExternalProject_Add( MYPROJECT
URL ${CMAKE_CURRENT_SOURCE_DIR}
CMAKE_ARGS -DCMAKE_C_COMPILER=${C_ALTERNATE_COMPILER}
    -DCMAKE_CXX_COMPILER=${CXX_ALTERNATE_COMPILER}
    -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
    -DEP_BUILD=TRUE
INSTALL_COMMAND ""
)
EP_ForceBuild( MYPROJECT )

I use the -DEP_BUILD=TRUE as an extra safety to prevent infinite
recursion -- if the user supplied a non OpenMP capable compiler as the
ALTERNATE_COMPILER.

So, I think the problem is with my use of 'URL
${CMAKE_CURRENT_SOURCE_DIR}'.  Is there a better way to achieve the
same thing?

Thanks in advance,

Rob
-- 

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

Reply via email to