#------------------------------------------------------------------- # This file is part of the CMake build system for Scol # # The contents of this file are placed in the public domain. Feel # free to make use of it in any way you like. #------------------------------------------------------------------- # Configure settings and install targets set(Scol_RELEASE_PATH "Release") set(Scol_RELWDBG_PATH "RelWithDebInfo") set(Scol_MINSIZE_PATH "MinSizeRel") set(Scol_DEBUG_PATH "Debug") set(Scol_LIB_RELEASE_PATH "Release") set(Scol_LIB_RELWDBG_PATH "RelWithDebInfo") set(Scol_LIB_MINSIZE_PATH "MinSizeRel") set(Scol_LIB_DEBUG_PATH "Debug") set(Scol_PLUGIN_PATH "/Plugins") if(RPI OR UNIX) set(Scol_BIN_PATH "") set(Scol_LIB_PATH "") else() set(Scol_BIN_PATH "bin/") set(Scol_LIB_PATH "lib/") endif() # Define _DEBUG for all platforms for debug builds set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG") # create vcproj.user file for Visual Studio to set debug working directory function(scol_create_vcproj_userfile TARGETNAME) if (MSVC) configure_file( ${Scol_TEMPLATES_DIR}/VisualStudioUserFile.vcproj.user.in ${CMAKE_CURRENT_BINARY_DIR}/${TARGETNAME}.vcproj.user @ONLY ) endif () endfunction(scol_create_vcproj_userfile) # install targets according to current build type function(scol_install_target TARGETNAME SUFFIX) install(TARGETS ${TARGETNAME} BUNDLE DESTINATION "${Scol_BIN_PATH}${Scol_RELEASE_PATH}${SUFFIX}" CONFIGURATIONS Release None "" RUNTIME DESTINATION "${Scol_BIN_PATH}${Scol_RELEASE_PATH}${SUFFIX}" CONFIGURATIONS Release None "" LIBRARY DESTINATION "${Scol_LIB_PATH}${Scol_LIB_RELEASE_PATH}${SUFFIX}" CONFIGURATIONS Release None "" ARCHIVE DESTINATION "${Scol_LIB_PATH}${Scol_LIB_RELEASE_PATH}${SUFFIX}" CONFIGURATIONS Release None "" FRAMEWORK DESTINATION "${Scol_BIN_PATH}${Scol_RELEASE_PATH}${SUFFIX}" CONFIGURATIONS Release None "" ) install(TARGETS ${TARGETNAME} BUNDLE DESTINATION "${Scol_BIN_PATH}${Scol_RELWDBG_PATH}${SUFFIX}" CONFIGURATIONS RelWithDebInfo RUNTIME DESTINATION "${Scol_BIN_PATH}${Scol_RELWDBG_PATH}${SUFFIX}" CONFIGURATIONS RelWithDebInfo LIBRARY DESTINATION "${Scol_LIB_PATH}${Scol_LIB_RELWDBG_PATH}${SUFFIX}" CONFIGURATIONS RelWithDebInfo ARCHIVE DESTINATION "${Scol_LIB_PATH}${Scol_LIB_RELWDBG_PATH}${SUFFIX}" CONFIGURATIONS RelWithDebInfo FRAMEWORK DESTINATION "${Scol_BIN_PATH}${Scol_RELWDBG_PATH}${SUFFIX}" CONFIGURATIONS RelWithDebInfo ) install(TARGETS ${TARGETNAME} BUNDLE DESTINATION "${Scol_BIN_PATH}${Scol_MINSIZE_PATH}${SUFFIX}" CONFIGURATIONS MinSizeRel RUNTIME DESTINATION "${Scol_BIN_PATH}${Scol_MINSIZE_PATH}${SUFFIX}" CONFIGURATIONS MinSizeRel LIBRARY DESTINATION "${Scol_LIB_PATH}${Scol_LIB_MINSIZE_PATH}${SUFFIX}" CONFIGURATIONS MinSizeRel ARCHIVE DESTINATION "${Scol_LIB_PATH}${Scol_LIB_MINSIZE_PATH}${SUFFIX}" CONFIGURATIONS MinSizeRel FRAMEWORK DESTINATION "${Scol_BIN_PATH}${Scol_MINSIZE_PATH}${SUFFIX}" CONFIGURATIONS MinSizeRel ) install(TARGETS ${TARGETNAME} BUNDLE DESTINATION "${Scol_BIN_PATH}${Scol_DEBUG_PATH}${SUFFIX}" CONFIGURATIONS Debug RUNTIME DESTINATION "${Scol_BIN_PATH}${Scol_DEBUG_PATH}${SUFFIX}" CONFIGURATIONS Debug LIBRARY DESTINATION "${Scol_LIB_PATH}${Scol_LIB_DEBUG_PATH}${SUFFIX}" CONFIGURATIONS Debug ARCHIVE DESTINATION "${Scol_LIB_PATH}${Scol_LIB_DEBUG_PATH}${SUFFIX}" CONFIGURATIONS Debug FRAMEWORK DESTINATION "${Scol_BIN_PATH}${Scol_DEBUG_PATH}${SUFFIX}" CONFIGURATIONS Debug ) if (NOT APPLE) if(CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") add_custom_command(TARGET ${TARGETNAME} POST_BUILD COMMAND ${CMAKE_STRIP} --strip-debug $ COMMENT "Stripping debug symbols from ${TARGETNAME}.so" ) endif() endif() endfunction(scol_install_target) # setup common target settings function(scol_config_common TARGETNAME) if (NOT APPLE_IOS) set_target_properties(${TARGETNAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${Scol_BINARY_DIR}/lib LIBRARY_OUTPUT_DIRECTORY ${Scol_BINARY_DIR}/lib RUNTIME_OUTPUT_DIRECTORY ${Scol_BINARY_DIR}/bin ) endif() scol_create_vcproj_userfile(${TARGETNAME}) if (Scol_STATIC) set(SCOL_LIBRARIES ${SCOL_LIBRARIES} ${TARGETNAME} CACHE INTERNAL "" FORCE) add_definitions("-DSCOL_STATIC") endif() endfunction(scol_config_common) # add plugin include path function(scol_include_plugin TARGETNAME TARGETPATH INCFILE) if (Scol_STATIC) FIND_PATH(SCOL_${TARGETNAME}_INCLUDE ${INCFILE} HINTS ${TARGETPATH} PATH_SUFFIXES include NO_DEFAULT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH) set(SCOL_INCLUDES ${SCOL_INCLUDES} ${SCOL_${TARGETNAME}_INCLUDE} CACHE INTERNAL "" FORCE) mark_as_advanced(FORCE SCOL_${TARGETNAME}_INCLUDE) if (SCOL_${TARGETNAME}_INCLUDE) set(SCOL_PREPROCESSOR "${SCOL_PREPROCESSOR} -DSCOL_${TARGETNAME}_LOAD" CACHE INTERNAL "" FORCE) #message(STATUS "SCOL_PREPROCESSOR : ${SCOL_PREPROCESSOR}") endif (SCOL_${TARGETNAME}_INCLUDE) endif(Scol_STATIC) endfunction(scol_include_plugin) # setup library build function(scol_config_lib LIBNAME) scol_config_common(${LIBNAME}) scol_install_target(${LIBNAME} "") # install debug pdb files if (Scol_INSTALL_PDB) install(FILES ${Scol_BINARY_DIR}/bin${Scol_DEBUG_PATH}/${LIBNAME}.pdb DESTINATION bin${Scol_DEBUG_PATH} CONFIGURATIONS Debug ) install(FILES ${Scol_BINARY_DIR}/bin${Scol_RELWDBG_PATH}/${LIBNAME}.pdb DESTINATION bin${Scol_RELWDBG_PATH} CONFIGURATIONS RelWithDebInfo ) endif () endfunction(scol_config_lib) function(scol_config_exe LIBNAME) if (NOT APPLE_IOS) set_target_properties(${LIBNAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${Scol_BINARY_DIR}/lib LIBRARY_OUTPUT_DIRECTORY ${Scol_BINARY_DIR}/lib RUNTIME_OUTPUT_DIRECTORY ${Scol_BINARY_DIR}/bin ) endif() scol_create_vcproj_userfile(${LIBNAME}) if (Scol_STATIC) add_definitions("-DSCOL_STATIC") endif() if (NOT APPLE_IOS) scol_install_target(${LIBNAME} "") endif() if (Scol_INSTALL_PDB) # install debug pdb files install(FILES ${Scol_BINARY_DIR}/lib${Scol_DEBUG_PATH}/${LIBNAME}.pdb DESTINATION bin${Scol_DEBUG_PATH} CONFIGURATIONS Debug ) install(FILES ${Scol_BINARY_DIR}/lib${Scol_RELWDBG_PATH}/${LIBNAME}.pdb DESTINATION bin${Scol_RELWDBG_PATH} CONFIGURATIONS RelWithDebInfo ) endif () endfunction(scol_config_exe) function(scol_config_component LIBNAME) scol_config_common(${LIBNAME}) scol_install_target(${LIBNAME} "") if (Scol_INSTALL_PDB) # install debug pdb files install(FILES ${Scol_BINARY_DIR}/lib${Scol_DEBUG_PATH}/${LIBNAME}.pdb DESTINATION bin${Scol_DEBUG_PATH} CONFIGURATIONS Debug ) install(FILES ${Scol_BINARY_DIR}/lib${Scol_RELWDBG_PATH}/${LIBNAME}.pdb DESTINATION bin${Scol_RELWDBG_PATH} CONFIGURATIONS RelWithDebInfo ) endif () endfunction(scol_config_component) # setup plugin build function(scol_config_plugin PLUGINNAME) scol_config_common(${PLUGINNAME}) scol_install_target(${PLUGINNAME} ${Scol_PLUGIN_PATH}) if (Scol_INSTALL_PDB) # install debug pdb files install(FILES ${Scol_BINARY_DIR}/bin${Scol_DEBUG_PATH}/${PLUGINNAME}.pdb DESTINATION bin${Scol_DEBUG_PATH} CONFIGURATIONS Debug ) install(FILES ${Scol_BINARY_DIR}/bin${Scol_RELWDBG_PATH}/${PLUGINNAME}.pdb DESTINATION bin${Scol_RELWDBG_PATH} CONFIGURATIONS RelWithDebInfo ) endif () endfunction(scol_config_plugin)