<commit_before>#--------------------------------------------------------------------
# Inviwo Qt Application
ivw_project(inviwo)

find_package(Qt5Core QUIET REQUIRED)
find_package(Qt5Gui QUIET REQUIRED)
find_package(Qt5Widgets QUIET REQUIRED)
find_package(Qt5Help QUIET REQUIRED)

#--------------------------------------------------------------------
# Add MOC files
set(MOC_FILES  ${IVW_APPLICATION_DIR}/inviwo/inviwosplashscreen.h)

#--------------------------------------------------------------------
# Add header files
set(HEADER_FILES  ${MOC_FILES})
ivw_group("Header Files" ${HEADER_FILES})

#--------------------------------------------------------------------
# Add source files
set(SOURCE_FILES
    ${IVW_APPLICATION_DIR}/inviwo/inviwo.cpp
    ${IVW_APPLICATION_DIR}/inviwo/inviwosplashscreen.cpp
)
ivw_group("Source Files" ${SOURCE_FILES})

ivw_qt_wrap_cpp(MOC_FILES ${HEADER_FILES})
source_group("MOC Files" FILES ${MOC_FILES})
source_group("Resource Files" FILES ${IVW_RESOURCES_DIR}/inviwo.qrc)

#--------------------------------------------------------------------
# Add resource file
qt5_add_resources(QRC_FILE "${IVW_RESOURCES_DIR}/inviwo.qrc")
ivw_define_qt_definitions()
        
#--------------------------------------------------------------------
# Define libraries that should be linked
ivw_retrieve_all_modules(package_list)
list(APPEND package_list InviwoQtEditor)
list(APPEND package_list InviwoCore)
# Only include one OpenGL context creation module
if(IVW_USE_GLFW_NOT_OPENGLQT)
    list(REMOVE_ITEM package_list InviwoOpenGLQtModule)
else()
    list(REMOVE_ITEM package_list InviwoGLFWModule)
endif()

#--------------------------------------------------------------------
# Remove modules not used by this app
list(REMOVE_ITEM package_list InviwoGLUTModule)
list(REMOVE_ITEM package_list InviwoSDLModule)

#--------------------------------------------------------------------
# Register the use of modules
ivw_register_use_of_modules(${package_list})

#--------------------------------------------------------------------
# Need to add dependent directories before creating application
ivw_add_dependency_directories(${package_list})

set(RES_FILES "")
if(WIN32)
    set(RES_FILES ${RES_FILES} "${IVW_RESOURCES_DIR}/inviwo.rc")
elseif(APPLE)
    string(TIMESTAMP YEAR "%Y")
    set(MACOSX_BUNDLE_BUNDLE_NAME          Inviwo)
    set(MACOSX_BUNDLE_GUI_IDENTIFIER       "Inviwo")
    set(MACOSX_BUNDLE_ICON_FILE            inviwo_light.icns)
    set(MACOSX_BUNDLE_INFO_STRING          "Inviwo ${IVW_VERSION}, Copyright (c) 2012-${YEAR} Inviwo Foundation")
    set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${IVW_VERSION}")
    set(MACOSX_BUNDLE_LONG_VERSION_STRING  "${IVW_VERSION}.")
    set(MACOSX_BUNDLE_BUNDLE_VERSION       "${IVW_VERSION}")
    set(MACOSX_BUNDLE_COPYRIGHT            "(C) 2012-${YEAR} Inviwo Foundation")
    set_source_files_properties(${IVW_ROOT_DIR}/resources/icons/inviwo_light.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
    set(RES_FILES ${RES_FILES} ${IVW_ROOT_DIR}/resources/icons/inviwo_light.icns)
endif()

#--------------------------------------------------------------------
# Create application
add_executable(inviwo MACOSX_BUNDLE WIN32 
    ${SOURCE_FILES} 
    ${HEADER_FILES} 
    ${MOC_FILES} 
    ${QRC_FILE} 
    ${RES_FILES})

#--------------------------------------------------------------------
# Define defintions
ivw_define_standard_definitions(inviwo inviwo)

#--------------------------------------------------------------------
# Define standard properties
ivw_define_standard_properties(inviwo)

#--------------------------------------------------------------------
# Add application to pack
if(IVW_PACKAGE_PROJECT)
    if(WIN32)
        install(TARGETS inviwo RUNTIME DESTINATION bin COMPONENT qt_app)

    elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
        #Following http://www.cmake.org/Wiki/BundleUtilitiesExample

        install(
            TARGETS inviwo 
            RUNTIME   DESTINATION bin 
            BUNDLE    DESTINATION . 
            ARCHIVE   DESTINATION Inviwo.app/Contents/MacOS/ 
            LIBRARY   DESTINATION Inviwo.app/Contents/MacOS/ 
            COMPONENT qt_app
        )

        set(plugin_dest_dir Inviwo.app/Contents/MacOS)
        set(qtconf_dest_dir Inviwo.app/Contents/Resources)
        set(APPS "\${CMAKE_INSTALL_PREFIX}/Inviwo.app/Contents/MacOS/Inviwo")
        set(DIRS "\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/")
        
        # get link errors with out this line.
        install(CODE "file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"\")" COMPONENT qt_app)
        
        install(CODE "set(BU_CHMOD_BUNDLE_ITEMS ON)
                      include(BundleUtilities)
                      file(GLOB_RECURSE LIBS1 \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}\")
                      file(GLOB_RECURSE LIBS2 \"\${CMAKE_INSTALL_PREFIX}/Inviwo.app/Contents/plugins/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
                      fixup_bundle(\"${APPS}\" \"\${LIBS1};\${LIBS2}\" \"${DIRS}\")"
                COMPONENT qt_app
        )

        install(
            DIRECTORY   ${IVW_ROOT_DIR}/data/ 
            DESTINATION Inviwo.app/Contents/Resources/data
            COMPONENT   qt_app
        )

        set(CPACK_BINARY_DRAGNDROP ON)

    else()
        install(
            TARGETS   inviwo
            RUNTIME   DESTINATION bin
            BUNDLE    DESTINATION bin
            ARCHIVE   DESTINATION lib
            LIBRARY   DESTINATION lib
            COMPONENT qt_app
        )
    endif()
endif()

#--------------------------------------------------------------------
# Add dependencies
ivw_add_dependencies(${package_list})

#--------------------------------------------------------------------
# Optimize compilation with pre-compilied headers based on inviwo-core
#ivw_compile_optimize_inviwo_core()

ivw_memleak_setup(inviwo)

#--------------------------------------------------------------------
# add a console version of inviwo.exe called inviwo-cli.exe
if(WIN32)
    set_property(TARGET inviwo APPEND_STRING PROPERTY LINK_FLAGS <commit_msg>Core: inviwo/inviwo-dev#1362 Removed module dependencies for inviwo application. Should only be performed when dynamically loading modules.<commit_after>#--------------------------------------------------------------------
# Inviwo Qt Application
ivw_project(inviwo)

find_package(Qt5Core QUIET REQUIRED)
find_package(Qt5Gui QUIET REQUIRED)
find_package(Qt5Widgets QUIET REQUIRED)
find_package(Qt5Help QUIET REQUIRED)

#--------------------------------------------------------------------
# Add MOC files
set(MOC_FILES  ${IVW_APPLICATION_DIR}/inviwo/inviwosplashscreen.h)

#--------------------------------------------------------------------
# Add header files
set(HEADER_FILES  ${MOC_FILES})
ivw_group("Header Files" ${HEADER_FILES})

#--------------------------------------------------------------------
# Add source files
set(SOURCE_FILES
    ${IVW_APPLICATION_DIR}/inviwo/inviwo.cpp
    ${IVW_APPLICATION_DIR}/inviwo/inviwosplashscreen.cpp
)
ivw_group("Source Files" ${SOURCE_FILES})

ivw_qt_wrap_cpp(MOC_FILES ${HEADER_FILES})
source_group("MOC Files" FILES ${MOC_FILES})
source_group("Resource Files" FILES ${IVW_RESOURCES_DIR}/inviwo.qrc)

#--------------------------------------------------------------------
# Add resource file
qt5_add_resources(QRC_FILE "${IVW_RESOURCES_DIR}/inviwo.qrc")
ivw_define_qt_definitions()
        
#--------------------------------------------------------------------
# Define libraries that should be linked
ivw_retrieve_all_modules(package_list)
list(APPEND package_list InviwoQtEditor)
list(APPEND package_list InviwoCore)
# Only include one OpenGL context creation module
if(IVW_USE_GLFW_NOT_OPENGLQT)
    list(REMOVE_ITEM package_list InviwoOpenGLQtModule)
else()
    list(REMOVE_ITEM package_list InviwoGLFWModule)
endif()

#--------------------------------------------------------------------
# Remove modules not used by this app
list(REMOVE_ITEM package_list InviwoGLUTModule)
list(REMOVE_ITEM package_list InviwoSDLModule)

#--------------------------------------------------------------------
# Register the use of modules
ivw_register_use_of_modules(${package_list})

#--------------------------------------------------------------------
# Need to add dependent directories before creating application
set(${core_dependencies} InviwoQtEditor)
list(APPEND core_dependencies InviwoQtEditor)
list(APPEND core_dependencies InviwoCore)
list(APPEND core_dependencies InviwoQtWidgets)
ivw_add_dependency_directories(${core_dependencies})

set(RES_FILES "")
if(WIN32)
    set(RES_FILES ${RES_FILES} "${IVW_RESOURCES_DIR}/inviwo.rc")
elseif(APPLE)
    string(TIMESTAMP YEAR "%Y")
    set(MACOSX_BUNDLE_BUNDLE_NAME          Inviwo)
    set(MACOSX_BUNDLE_GUI_IDENTIFIER       "Inviwo")
    set(MACOSX_BUNDLE_ICON_FILE            inviwo_light.icns)
    set(MACOSX_BUNDLE_INFO_STRING          "Inviwo ${IVW_VERSION}, Copyright (c) 2012-${YEAR} Inviwo Foundation")
    set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${IVW_VERSION}")
    set(MACOSX_BUNDLE_LONG_VERSION_STRING  "${IVW_VERSION}.")
    set(MACOSX_BUNDLE_BUNDLE_VERSION       "${IVW_VERSION}")
    set(MACOSX_BUNDLE_COPYRIGHT            "(C) 2012-${YEAR} Inviwo Foundation")
    set_source_files_properties(${IVW_ROOT_DIR}/resources/icons/inviwo_light.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
    set(RES_FILES ${RES_FILES} ${IVW_ROOT_DIR}/resources/icons/inviwo_light.icns)
endif()

#--------------------------------------------------------------------
# Create application
add_executable(inviwo MACOSX_BUNDLE WIN32 
    ${SOURCE_FILES} 
    ${HEADER_FILES} 
    ${MOC_FILES} 
    ${QRC_FILE} 
    ${RES_FILES})

#--------------------------------------------------------------------
# Define defintions
ivw_define_standard_definitions(inviwo inviwo)

#--------------------------------------------------------------------
# Define standard properties
ivw_define_standard_properties(inviwo)

#--------------------------------------------------------------------
# Add application to pack
if(IVW_PACKAGE_PROJECT)
    if(WIN32)
        install(TARGETS inviwo RUNTIME DESTINATION bin COMPONENT qt_app)

    elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
        #Following http://www.cmake.org/Wiki/BundleUtilitiesExample

        install(
            TARGETS inviwo 
            RUNTIME   DESTINATION bin 
            BUNDLE    DESTINATION . 
            ARCHIVE   DESTINATION Inviwo.app/Contents/MacOS/ 
            LIBRARY   DESTINATION Inviwo.app/Contents/MacOS/ 
            COMPONENT qt_app
        )

        set(plugin_dest_dir Inviwo.app/Contents/MacOS)
        set(qtconf_dest_dir Inviwo.app/Contents/Resources)
        set(APPS "\${CMAKE_INSTALL_PREFIX}/Inviwo.app/Contents/MacOS/Inviwo")
        set(DIRS "\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}/")
        
        # get link errors with out this line.
        install(CODE "file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"\")" COMPONENT qt_app)
        
        install(CODE "set(BU_CHMOD_BUNDLE_ITEMS ON)
                      include(BundleUtilities)
                      file(GLOB_RECURSE LIBS1 \"\${CMAKE_INSTALL_PREFIX}/${plugin_dest_dir}\")
                      file(GLOB_RECURSE LIBS2 \"\${CMAKE_INSTALL_PREFIX}/Inviwo.app/Contents/plugins/*${CMAKE_SHARED_LIBRARY_SUFFIX}\")
                      fixup_bundle(\"${APPS}\" \"\${LIBS1};\${LIBS2}\" \"${DIRS}\")"
                COMPONENT qt_app
        )

        install(
            DIRECTORY   ${IVW_ROOT_DIR}/data/ 
            DESTINATION Inviwo.app/Contents/Resources/data
            COMPONENT   qt_app
        )

        set(CPACK_BINARY_DRAGNDROP ON)

    else()
        install(
            TARGETS   inviwo
            RUNTIME   DESTINATION bin
            BUNDLE    DESTINATION bin
            ARCHIVE   DESTINATION lib
            LIBRARY   DESTINATION lib
            COMPONENT qt_app
        )
    endif()
endif()

#--------------------------------------------------------------------
# Add dependencies
ivw_add_dependencies(${core_dependencies})

#--------------------------------------------------------------------
# Optimize compilation with pre-compilied headers based on inviwo-core
#ivw_compile_optimize_inviwo_core()

ivw_memleak_setup(inviwo)

#--------------------------------------------------------------------
# add a console version of inviwo.exe called inviwo-cli.exe
if(WIN32)
    set_property(TARGET inviwo APPEND_STRING PROPERTY LINK_FLAGS 
{'fraction_non_alphanumeric': 0.2511980830670926, 'fraction_numerical': 0.0043130990415335465, 'mean_word_length': 1.8411617880644429, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5599010', 'n_tokens_mistral': 3904, 'n_tokens_neox': 3712, 'n_words': 620}