cmake_minimum_required (VERSION 3.0) project (sge_executable) if(INVRS_SOURCE_DIR) include_directories (${INVRS_TARGET_INCLUDE_DIR}) link_directories (${inVRs_TARGET_LIB_DIR}) find_package(OpenSG REQUIRED COMPONENTS OSGBase OSGSystem OSGDrawable OSGUtil OSGGroup OSGWindow OSGState) include_directories(${OpenSG_INCLUDE_DIRS}) find_package(VRPN REQUIRED) include_directories(${VRPN_INCLUDE_DIRS}) include_directories(${VRPN_INCLUDE_DIR}/vrpn) add_definitions(${VRPN_DEFINITIONS}) ####################################################################### # Ensure that CAVESceneManager sources are available ####################################################################### find_file(CAVESCENEMANAGER_CHECK_HEADER OSGCSM/OSGCAVESceneManager.h ${INVRS_SOURCE_DIR}/external/CAVESceneManager-1.0/include) mark_as_advanced(CAVESCENEMANAGER_CHECK_HEADER) mark_as_advanced (FORCE CAVESceneManager_ROOT_DIR) # TODO: make error message more clear, this should never happen!!! if (NOT CAVESCENEMANAGER_CHECK_HEADER) message(FATAL_ERROR "ERROR: OpenSGApplicationBase can not be built without CAVESceneManager library. " "Please download CAVESceneManager from http://www.inVRs.org " "and unpack it in the /external folder!") endif (NOT CAVESCENEMANAGER_CHECK_HEADER) ####################################################################### # Add CAVESceneManager include directory and set the required libraries ####################################################################### include_directories(${INVRS_SOURCE_DIR}/external/CAVESceneManager-1.0/include ${INVRS_SOURCE_DIR}/external/CAVESceneManager-1.0/include/OpenSG) include_directories(${INVRS_SOURCE_DIR}/external/avatara-1.0/include) include_directories(${INVRS_SOURCE_DIR}) endif(INVRS_SOURCE_DIR) if(NOT INVRS_SOURCE_DIR) ################################# # if we are not in the inVRs source dir and build individually # we need to find the inVRs include and library dirs ################################# if(NOT INVRS_SOURCE_DIR) find_path(inVRs_INCLUDE_DIR NAMES inVRs/config_inVRs.cmake NO_DEFAULT_PATH) find_path(inVRs_LIBRARY_DIR NAMES libinVRsSystemCore NO_DEFAULT_PATH) endif(NOT INVRS_SOURCE_DIR) include_directories(${inVRs_INCLUDE_DIR}) include_directories(${inVRs_INCLUDE_DIR}/inVRs) include_directories(${inVRs_INCLUDE_DIR}/inVRs/tools/libraries) link_directories(${inVRs_LIBRARY_DIR}) ################################## # boost is needed, at least for now. some dependency always tries to find it like this ################################## set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_MULTITHREADED ON) set(Boost_USE_STATIC_RUNTIME OFF) find_package(Boost COMPONENTS filesystem system) mark_as_advanced(CLEAR Boost_INCLUDE_DIR) mark_as_advanced(CLEAR Boost_FILESYSTEM_LIBRARY_DEBUG) mark_as_advanced(CLEAR Boost_FILESYSTEM_LIBRARY_RELEASE) mark_as_advanced(CLEAR Boost_SYSTEM_LIBRARY_DEBUG) mark_as_advanced(CLEAR Boost_SYSTEM_LIBRARY_RELEASE) include_directories(${Boost_INCLUDE_DIR}) link_directories(${Boost_LIBRARY_DIR}) ################################## # OpenSG is included. This tends to be a bit weird, read comments ################################## find_package(OpenSG REQUIRED COMPONENTS OSGBase OSGSystem OSGDrawable OSGUtil OSGGroup OSGWindow OSGState) #for some reason the normal debug/release libraries are set to advanced #and the DEBUGOPT/RELEASENOOP are set to not advanced #mark the ones we actually need as NOT advanced mark_as_advanced(CLEAR OpenSG_OSGBASE_LIBRARY_DEBUG) mark_as_advanced(CLEAR OpenSG_OSGSYSTEM_LIBRARY_DEBUG) mark_as_advanced(CLEAR OpenSG_OSGUTIL_LIBRARY_DEBUG) mark_as_advanced(CLEAR OpenSG_OSGGROUP_LIBRARY_DEBUG) mark_as_advanced(CLEAR OpenSG_OSGWINDOW_LIBRARY_DEBUG) mark_as_advanced(CLEAR OpenSG_OSGSTATE_LIBRARY_DEBUG) mark_as_advanced(CLEAR OpenSG_OSGDRAWABLE_LIBRARY_DEBUG) mark_as_advanced(CLEAR OpenSG_OSGBASE_LIBRARY_RELEASE) mark_as_advanced(CLEAR OpenSG_OSGSYSTEM_LIBRARY_RELEASE) mark_as_advanced(CLEAR OpenSG_OSGUTIL_LIBRARY_RELEASE) mark_as_advanced(CLEAR OpenSG_OSGGROUP_LIBRARY_RELEASE) mark_as_advanced(CLEAR OpenSG_OSGWINDOW_LIBRARY_RELEASE) mark_as_advanced(CLEAR OpenSG_OSGSTATE_LIBRARY_RELEASE) mark_as_advanced(CLEAR OpenSG_OSGDRAWABLE_LIBRARY_RELEASE) #mark the ones we actually do not need (or do not have in the normal package) as advanced mark_as_advanced(OpenSG_OSGBASE_LIBRARY_DEBUGOPT) mark_as_advanced(OpenSG_OSGSYSTEM_LIBRARY_DEBUGOPT) mark_as_advanced(OpenSG_OSGUTIL_LIBRARY_DEBUGOPT) mark_as_advanced(OpenSG_OSGGROUP_LIBRARY_DEBUGOPT) mark_as_advanced(OpenSG_OSGWINDOW_LIBRARY_DEBUGOPT) mark_as_advanced(OpenSG_OSGSTATE_LIBRARY_DEBUGOPT) mark_as_advanced(OpenSG_OSGDRAWABLE_LIBRARY_DEBUGOPT) mark_as_advanced(OpenSG_OSGBASE_LIBRARY_RELEASENOOPT) mark_as_advanced(OpenSG_OSGSYSTEM_LIBRARY_RELEASENOOPT) mark_as_advanced(OpenSG_OSGUTIL_LIBRARY_RELEASENOOPT) mark_as_advanced(OpenSG_OSGGROUP_LIBRARY_RELEASENOOPT) mark_as_advanced(OpenSG_OSGWINDOW_LIBRARY_RELEASENOOPT) mark_as_advanced(OpenSG_OSGSTATE_LIBRARY_RELEASENOOPT) mark_as_advanced(OpenSG_OSGDRAWABLE_LIBRARY_RELEASENOOPT) include_directories(${OpenSG_INCLUDE_DIRS}) set(OPENSG_MODULES_RELEASE optimized ${OpenSG_OSGBASE_LIBRARY_RELEASE} optimized ${OpenSG_OSGSYSTEM_LIBRARY_RELEASE} optimized ${OpenSG_OSGUTIL_LIBRARY_RELEASE} optimized ${OpenSG_OSGGROUP_LIBRARY_RELEASE} optimized ${OpenSG_OSGWINDOW_LIBRARY_RELEASE} optimized ${OpenSG_OSGSTATE_LIBRARY_RELEASE} optimized ${OpenSG_OSGDRAWABLE_LIBRARY_RELEASE}) set(OPENSG_MODULES_DEBUG debug ${OpenSG_OSGBASE_LIBRARY_DEBUG} debug ${OpenSG_OSGSYSTEM_LIBRARY_DEBUG} debug ${OpenSG_OSGUTIL_LIBRARY_DEBUG} debug ${OpenSG_OSGGROUP_LIBRARY_DEBUG} debug ${OpenSG_OSGWINDOW_LIBRARY_DEBUG} debug ${OpenSG_OSGSTATE_LIBRARY_DEBUG} debug ${OpenSG_OSGDRAWABLE_LIBRARY_DEBUG}) endif(NOT INVRS_SOURCE_DIR) set(SGE_OSG_USE_CUSTOM_ATTRIBUTES true CACHE BOOL "Enable custom shader attributes. Needs to be enabled in OpenSG Library. Required for non-NVIDIA cards") ################################## # easy access to our own headers ################################## include_directories("${PROJECT_SOURCE_DIR}") ################################## # source files are specified in the individual folders to make it easier to read and maintain (imho at least) ################################## include(gui/cmake.txt) include(gui/materials/cmake.txt) include(gui/objects/cmake.txt) include(gui/scenegraph/cmake.txt) include(gui/viewpoints/cmake.txt) include(backend/cmake.txt) include(backend/scenemanagers/cmake.txt) ################################## # Instruct CMake to run moc automatically when needed. ################################## set(CMAKE_AUTOMOC ON) # Find the QtWidgets library find_package(Qt5Widgets) find_package(Qt5Core) find_package(Qt5Gui) ################################## # Tell CMake to create the executable ################################## add_executable(sge WIN32 main.cpp stdafx.h stdafx.cpp ${SGE_GUI_SOURCE_FILES} ${SGE_GUI_MATERIALS_SOURCE_FILES} ${SGE_GUI_OBJECTS_SOURCE_FILES} ${SGE_GUI_SCENEGRAPH_SOURCE_FILES} ${SGE_GUI_VIEWPOINTS_SOURCE_FILES} ${SGE_BACKEND_SOURCE_FILES} ${SGE_BACKEND_SCENEMANAGERS_SOURCE_FILES}) ################################## #In Debug mode we want DEBUG to be defined so we get all the debug spam ... ehm ... output ################################## target_compile_definitions(sge PRIVATE $<$:DEBUG>) if(${SGE_OSG_USE_CUSTOM_ATTRIBUTES}) target_compile_definitions(sge PRIVATE SGE_USE_CUSTATT) endif(${SGE_OSG_USE_CUSTOM_ATTRIBUTES}) ################################## # group source files in Visual Studio to make it all nice and pretty ################################## SOURCE_GROUP("gui" FILES ${SGE_GUI_SOURCE_FILES}) SOURCE_GROUP("gui\\materials" FILES ${SGE_GUI_MATERIALS_SOURCE_FILES}) SOURCE_GROUP("gui\\objects" FILES ${SGE_GUI_OBJECTS_SOURCE_FILES}) SOURCE_GROUP("gui\\scenegraph" FILES ${SGE_GUI_SCENEGRAPH_SOURCE_FILES}) SOURCE_GROUP("gui\\viewpoints" FILES ${SGE_GUI_VIEWPOINTS_SOURCE_FILES}) SOURCE_GROUP("backend" FILES ${SGE_BACKEND_SOURCE_FILES}) SOURCE_GROUP("backend\\scenemanagers" FILES ${SGE_BACKEND_SCENEMANAGERS_SOURCE_FILES}) if(WIN32) set_target_properties(sge PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS") set_target_properties(sge PROPERTIES COMPILE_DEFINITIONS_DEBUG "_WINDOWS") set_target_properties(sge PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:WINDOWS") set_target_properties(sge PROPERTIES COMPILE_DEFINITIONS_RELWITHDEBINFO "_WINDOWS") set_target_properties(sge PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS") set_target_properties(sge PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS") endif(WIN32) if(INVRS_SOURCE_DIR) target_link_libraries(sge Qt5::Widgets Qt5::Core Qt5::Gui ${OpenSG_LIBRARIES} optimized ${VRPN_LIBRARIES} debug ${VRPN_LIBRARIES_DEBUG} avatara CAVESceneManager inVRsTextureManager inVRsSkybox) install(TARGETS sge RUNTIME DESTINATION ${INVRS_TARGET_BIN_DIR}/sge) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../icons DESTINATION ${INVRS_TARGET_BIN_DIR}/sge) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../avatar DESTINATION ${INVRS_TARGET_BIN_DIR}/sge) install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../textures DESTINATION ${INVRS_TARGET_BIN_DIR}/sge) endif(INVRS_SOURCE_DIR) if(NOT INVRS_SOURCE_DIR) target_link_libraries(sge Qt5::Widgets Qt5::Core Qt5::Gui ${OPENSG_MODULES_DEBUG} ${OPENSG_MODULES_RELEASE} debug ${Boost_SYSTEM_LIBRARY_DEBUG} optimized ${Boost_SYSTEM_LIBRARY_RELEASE} debug ${VRPN_LIBRARIES_DEBUG} optimized ${VRPN_LIBRARIES} avatara debug CAVESceneManagerD optimized CAVESceneManager inVRsTextureManager inVRsSkybox) install(TARGETS sge RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/sge) install(DIRECTORY ${CMAKE_SOURCE_DIR}/icons DESTINATION ${CMAKE_INSTALL_PREFIX}/sge) install(DIRECTORY ${CMAKE_SOURCE_DIR}/avatar DESTINATION ${CMAKE_INSTALL_PREFIX}/sge) install(DIRECTORY ${CMAKE_SOURCE_DIR}/textures DESTINATION ${CMAKE_INSTALL_PREFIX}/sge) endif(NOT INVRS_SOURCE_DIR)