[CMake] Multiple Configurations + Optional Targets Depending on Found Libraries

Gregory Peele ARA/CFD gpeele at ara.com
Mon Dec 13 19:01:19 EST 2010


I trying to support multiple configurations in a single binary directory (in my case for MSVC 2010) and ran into a situation that I'm not sure how to tackle.   I have a library target which links against OpenSceneGraph.  If OpenSceneGraph is not found, that target and everything that depends on it is not built since the 3D GUI is optional.

CMake snippet:

FIND_PACKAGE ("OpenSceneGraph")
IF (OPENSCENEGRAPH_FOUND)
                INCLUDE_DIRECTORIES (${OPENSCENEGRAPH_INCLUDE_DIRS})
                ADD_LIBRARY (LtfSceneBuilder ${SOURCES})
                TARGET_LINK_LIBRARIES (LtfSceneBuilder ${OPENSCENEGRAPH_LIBRARIES})
                INSTALL (TARGETS LtfSceneBuilder RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
ENDIF ()

With a multi-configuration build it is possible for Debug OSG to be found and not Release (or vice-versa) and I would like to support that case if possible.    Since this is Windows and OSG is heavy on memory allocation across DLL boundaries, it is not a good thing to mix and match Release and Debug.   Is there a way to add my library target only for a specific configuration based on whether the appropriate OSG libraries for that configuration were found?  I know the MSVC IDE has a way of setting projects to be built only in certain configurations but I am not sure if there is a way to do it from CMake and, if so, whether it plays nicely with INSTALL.

Currently if only Debug OSG is found, CMake generation fails due to NOT_FOUND values for the Release OSG libraries being referenced by the MSVC project.  If only Release OSG is found, CMake generation succeeds and the Debug build links against Release OSG libraries.

Ideas?

Thanks,

Gregory Peele, Jr.
Senior Scientist
Applied Research Associates, Inc.
Central Florida Division

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20101214/7ec0687b/attachment.htm>


More information about the CMake mailing list