# Generate examples. # # This is boilerplate code for generating a set of executables, one per # .cpp file in an "examples" subdirectory. These are intended to # be installed with the library but we don't handle installation # here. Unlike the similar boilerplate code in the "tests" # directory (but like the "tests/adhoc" boilerplate), this does # not generate CMake ADD_TEST commands so these will never run # automatically. # # For IDEs that can deal with PROJECT_LABEL properties (at least # Visual Studio) the projects for building each of these adhoc # executables will be labeled "Example - TheExampleName" if a file # TheExampleName.cpp is found in this directory. # # We check the BUILD_TESTING_{SHARED,STATIC} variables to determine # whether to build dynamically linked, statically linked, or both # versions of the executable. FILE(GLOB EXAMPLES "*.cpp") FOREACH(EX_PROG ${EXAMPLES}) GET_FILENAME_COMPONENT(EX_ROOT ${EX_PROG} NAME_WE) IF (BUILD_TESTING_SHARED) # Link with shared library ADD_EXECUTABLE(${EX_ROOT} ${EX_PROG}) SET_TARGET_PROPERTIES(${EX_ROOT} PROPERTIES PROJECT_LABEL "Example - ${EX_ROOT}") TARGET_LINK_LIBRARIES(${EX_ROOT} ${SHARED_TARGET} debug ${SimTKSIMBODY_AUX_SHARED_LIBRARY}_d optimized ${SimTKSIMBODY_AUX_SHARED_LIBRARY}) if(APPLE) # ppc make seems to need explicit link to vtk lib, even for dynamic target_link_libraries(${EX_ROOT} ${VTK_LIBS_TO_USE}) endif(APPLE) ENDIF (BUILD_TESTING_SHARED) IF (BUILD_TESTING_STATIC) # Link with static library SET(EX_STATIC ${EX_ROOT}Static) ADD_EXECUTABLE(${EX_STATIC} ${EX_PROG}) SET_TARGET_PROPERTIES(${EX_STATIC} PROPERTIES COMPILE_FLAGS "-DSimTK_USE_STATIC_LIBRARIES" PROJECT_LABEL "Example - ${EX_STATIC}") TARGET_LINK_LIBRARIES(${EX_STATIC} ${STATIC_TARGET} debug ${SimTKSIMBODY_AUX_STATIC_LIBRARY}_d optimized ${SimTKSIMBODY_AUX_STATIC_LIBRARY} ${VTK_LIBS_TO_USE}) if(APPLE) target_link_libraries(${EX_STATIC} ${CARBON_FRAMEWORK}) endif(APPLE) ENDIF (BUILD_TESTING_STATIC) ENDFOREACH(EX_PROG ${ADHOC_TESTS})