Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cmake dep refactor #969

Merged
merged 19 commits into from Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 22 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,27 @@
Here we document changes that affect the public API or changes that needs to be communicated to other developers.

## 2020-06-26 Vcpkg support
Most of our external dependencies can now provided by vcpkg. Just install the corresponding vcpkg package and set `IVW_USE_EXTERNAL_<package>` to `TRUE`
petersteneteg marked this conversation as resolved.
Show resolved Hide resolved
`cmake/vcpkghelpers.cmake` provides functions for installing the vcpkg packages needed to create installers.

## 2020-06-26 CMake refactor
We have renamed many cmake options to make the naming more consistent and the options easier to find. But you might need to review your cmake settings when updating to make sure you have the correct settings.
We now group the cmake settings like this:
* `IVW_APP_*` Enable disable building various apps
* `IVV_CFG_*` All configuration options, like PRECOMPILED_HEADERS and PROFILING
* `IVW_DOXYGEN_*` Doxygen options
* `IVW_EXTERNAL_*` Add external modules / projects
* `IVW_MODULE_*` enable/disable modules
* `IVW_PACKAGE_*` options for installing/cretings installers
petersteneteg marked this conversation as resolved.
Show resolved Hide resolved
* `IVW_TEST_*` option for unit test, integration test, regressions test.
* `IVW_USE_*` options for enabling/disabling some libraries / tools (sigar, openmp, openexr)
* `IVW_USE_EXTERNAL_*` enable/disable building various dependences. if off then dependences must be provided externally

Notable changes include:
* `PRECOMPILED_HEADERS -> IVW_CFG_PRECOMPILED_HEADERS`
* `IVW_PROFILING -> IVW_CFG_PROFILING`
* `IVW_OPENMP_ON -> IVW_USE_OPENMP`

## 2020-06-16 StipplingProperty now in BaseGL
Moved StipplingProperty and associated settings from Base module to BaseGL.

Expand Down
116 changes: 44 additions & 72 deletions CMakeLists.txt
Expand Up @@ -27,13 +27,7 @@
#
#################################################################################

cmake_minimum_required(VERSION 3.12...3.17)
cmake_policy(VERSION 3.12.0)

if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()

cmake_minimum_required(VERSION 3.13...3.17 FATAL_ERROR)
string(TIMESTAMP timeStart "%Y-%m-%d %H:%M:%S")

#--------------------------------------------------------------------
Expand All @@ -54,17 +48,21 @@ set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)

# option for setting the project/solution name of the Inviwo project
set(IVW_PROJECT_NAME "inviwo-projects" CACHE STRING "Project/Solution name (default: inviwo-projects)")
project(${IVW_PROJECT_NAME})
set(IVW_CFG_PROJECT_NAME "inviwo-projects" CACHE STRING "Project/Solution name (default: inviwo-projects)")
project(${IVW_CFG_PROJECT_NAME}
HOMEPAGE_URL https://github.com/inviwo/inviwo
LANGUAGES CXX
)

#Verify that git submodules has been cloned
include(cmake/verifysubmodules.cmake)
verify_submodules("${CMAKE_CURRENT_LIST_DIR}/.gitmodules")

option(BUILD_SHARED_LIBS "Build shared libs, else static libs" ON)

# Needed for find_package(PythonLibsNew 3), which is an improved version of CMake shipped find_pythonLibs
set(CMAKE_MODULE_PATH "${CMAKE_BINARY_DIR}/pkg/;${CMAKE_MODULE_PATH};${CMAKE_SOURCE_DIR}/ext/pybind11/tools")
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/pkg)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake/modules)

# Make sure we do look for python 3 here, before it is done in any subdirectory or external library.
# If we do not specify version number on our first call to find_package(PythonLibs) it returns the
Expand All @@ -75,30 +73,37 @@ set(CMAKE_MODULE_PATH "${CMAKE_BINARY_DIR}/pkg/;${CMAKE_MODULE_PATH};${CMAKE_SOU
set(PythonLibsNew_FIND_VERSION 3)
set(Python_ADDITIONAL_VERSIONS 3.5 3.6 3.7 3.8 3.9)
if(IVW_MODULE_PYTHON3)
find_package(PythonLibsNew 3 REQUIRED)
find_package(PythonLibsNew 3 REQUIRED)
else()
find_package(PythonLibsNew 3)
find_package(PythonLibsNew 3)
endif()

include(cmake/globalconfig.cmake)

#--------------------------------------------------------------------
# Application setup
option(IVW_QT_APPLICATION_BASE
"Build base for Qt apps. Used by the Qt network editor and the Tiny Qt app" ON)
option(IVW_QT_APPLICATION "Build Inviwo Qt network editor application" ON)
option(IVW_INTEGRATION_TESTS "Build inviwo integration test" ON)
option(IVW_TINY_GLFW_APPLICATION "Build Inviwo Tiny GLFW Application" OFF)
option(IVW_TINY_QT_APPLICATION "Build Inviwo Tiny QT Application" OFF)

if(IVW_QT_APPLICATION AND NOT IVW_QT_APPLICATION_BASE)
set(IVW_QT_APPLICATION_BASE ON CACHE BOOL "Build base for qt applications. \
Used by Qt network editor and Qt minimal application" FORCE)
message(STATUS "IVW_QT_APPLICATION_BASE was set to build, due to dependency towards IVW_QT_APPLICATION")
option(IVW_APP_QTBASE "Build base for Qt apps. Used by the Qt network editor and the Tiny Qt app" ON)
option(IVW_APP_INVIWO "Build Inviwo Qt network editor application" ON)
option(IVW_APP_MINIMAL_GLFW "Build Inviwo Tiny GLFW Application" OFF)
option(IVW_APP_MINIMAL_QT "Build Inviwo Tiny QT Application" OFF)
option(IVW_APP_PYTHON "Build Inviwo Python Application" ON)

if((IVW_APP_INVIWO OR IVW_APP_MINIMAL_QT OR IVW_APP_PYTHON) AND NOT IVW_APP_QTBASE)
set(IVW_APP_QTBASE ON CACHE BOOL
"Build base for qt applications. Used by Qt network editor and Qt minimal application"
FORCE
)
message(STATUS "IVW_APP_QTBASE was set to build, due to dependencies")
endif()
ivw_enable_modules_if(IVW_QT_APPLICATION QtWidgets)
ivw_enable_modules_if(IVW_INTEGRATION_TESTS GLFW Base)
ivw_enable_modules_if(IVW_TINY_GLFW_APPLICATION GLFW)

ivw_enable_modules_if(IVW_APP_INVIWO QtWidgets)
ivw_enable_modules_if(IVW_APP_MINIMAL_QT QtWidgets)
ivw_enable_modules_if(IVW_APP_MINIMAL_GLFW GLFW)
ivw_enable_modules_if(IVW_APP_INVIWO_DOME SGCT)
ivw_enable_modules_if(IVW_APP_PYTHON Python3 Python3Qt QtWidgets)

option(IVW_TEST_INTEGRATION_TESTS "Build inviwo integration test" ON)
ivw_enable_modules_if(IVW_TEST_INTEGRATION_TESTS GLFW Base)

# Try to find qt and add it if it is not already in CMAKE_PREFIX_PATH
if(NOT "${CMAKE_PREFIX_PATH}" MATCHES "[Qq][Tt]")
Expand All @@ -112,52 +117,19 @@ endif()

add_custom_target(uninstall COMMENT "Dummy target to prevent other uninstalls")

#--------------------------------------------------------------------
# Add external libraries.
#
#
# Dependencies between libraries are solved using the given order
# Note: We prefer building dependencies our self to using find_library,
# since it does not necessarily give you the dll for packaging.
# It also ensures that we are in control of the used version
# and is built using the same, Inviwo, settings.

option (IVW_USE_EXTERNAL_IMG "Link with external image libraries (zlib, png, jpeg, tiff) instead of building them." OFF)
if (NOT IVW_USE_EXTERNAL_IMG)
add_subdirectory(ext/zlib-1.2.11) # Defines target ZLIB::ZLIB
add_subdirectory(ext/libpng) # Defines target PNG::PNG
add_subdirectory(ext/libjpeg) # Defines target JPEG::JPEG
add_subdirectory(ext/tiff) # Defines target TIFF::TIFF
add_subdirectory(ext) # Add external libraries.
add_subdirectory(tools/meta) # Add inviwo meta library, used in the qt editor
if(IVW_TEST_INTEGRATION_TESTS OR IVW_TEST_UNIT_TESTS)
add_subdirectory(tests/testutil) # Add test utils, used in the module unit tests
endif()
ivw_register_modules(all_modules) # Add inviwo modules
add_subdirectory(src/qt) # Add the Qt network editor
add_subdirectory(apps) # Add all the applications, uses the modules.
ivw_add_external_projects() # Add external projects
if(IVW_TEST_INTEGRATION_TESTS)
add_subdirectory(tests/integrationtests) # Add integration tests, uses the modules.
endif()

add_subdirectory(ext/flags)
add_subdirectory(ext/glm)
add_subdirectory(ext/ticpp)
add_subdirectory(ext/gtest)
add_subdirectory(ext/benchmark)
add_subdirectory(ext/warn)
add_subdirectory(ext/tclap)
add_subdirectory(ext/tinydir)
add_subdirectory(ext/half)
add_subdirectory(ext/utf)
add_subdirectory(ext/json)
add_subdirectory(ext/fmt)
add_subdirectory(ext/span)
add_subdirectory(ext/sml)
add_subdirectory(ext/sigar)
add_subdirectory(ext/stackwalker) # Add stackwalker for windows for stack traces in the log
add_subdirectory(tests/testutil)

ivw_register_modules(all_modules) # Add modules

add_subdirectory(tools/meta) # Add Inviwo meta
add_subdirectory(src/qt) # Add Qt
add_subdirectory(apps) # Add applications
ivw_add_external_projects() # Add external projects
add_subdirectory(tests/integrationtests) # Add integration tests project

# Generate Doxygen setup.
add_subdirectory(docs)
add_subdirectory(docs) # Generate Doxygen targets

string(TIMESTAMP time "%Y-%m-%d %H:%M:%S")
message(STATUS "Configure started at ${timeStart} and ended at ${time}")
9 changes: 4 additions & 5 deletions apps/CMakeLists.txt
@@ -1,13 +1,12 @@
if(IVW_TINY_GLFW_APPLICATION)
if(IVW_APP_MINIMAL_GLFW)
add_subdirectory(minimals/glfw)
endif()
if(IVW_TINY_QT_APPLICATION)
if(IVW_APP_MINIMAL_QT)
add_subdirectory(minimals/qt)
endif()
if(IVW_QT_APPLICATION)
if(IVW_APP_INVIWO)
add_subdirectory(inviwo)
endif()

if(IVW_MODULE_PYTHON3)
if(IVW_APP_PYTHON)
add_subdirectory(inviwopyapp)
endif()
45 changes: 10 additions & 35 deletions apps/inviwo/CMakeLists.txt
Expand Up @@ -66,10 +66,9 @@ ivw_define_standard_properties(inviwo)

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

elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# Configure Info.plist
# https://cmake.org/cmake/help/v3.15/prop_tgt/MACOSX_BUNDLE_INFO_PLIST.html
string(TIMESTAMP YEAR "%Y")
Expand All @@ -84,47 +83,23 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
MACOSX_BUNDLE_COPYRIGHT "C) 2012-${YEAR} Inviwo Foundation"
)
#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}/")

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 "file(WRITE \"\${CMAKE_INSTALL_PREFIX}/${qtconf_dest_dir}/qt.conf\" \"\")" COMPONENT Application)
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
COMPONENT Application
)

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()


# Add build dependency towards any pybind11 targets and inviwo,
# if python is not enabled, this list will be empty
if(_allPyBindWrappers)
Expand Down Expand Up @@ -171,14 +146,14 @@ if(WIN32)
set_property(TARGET inviwo-cli APPEND_STRING PROPERTY LINK_FLAGS
" /SUBSYSTEM:CONSOLE /ENTRY:mainCRTStartup")

install(TARGETS inviwo-cli RUNTIME DESTINATION bin COMPONENT qt_app)
ivw_default_install_targets(inviwo-cli)
endif()

# Save information for python tools.
ivw_mod_name_to_class(ivw_module_classes ${enabled_modules})
ivw_private_create_pyconfig("${IVW_MODULE_DIR};${IVW_EXTERNAL_MODULES}" "${ivw_module_classes}" inviwo)


ivw_deploy_qt(inviwo)

include(packaging/packaging.cmake) # Package creation
if(IVW_PACKAGE_SELECT_APP STREQUAL "inviwo")
include(packaging/packaging.cmake) # Package creation
endif()
petersteneteg marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion apps/inviwo/inviwosplashscreen.cpp
Expand Up @@ -54,7 +54,7 @@ void InviwoSplashScreen::show() {
void InviwoSplashScreen::drawContents(QPainter* painter) {
QString versionLabel;
QTextStream labelStream(&versionLabel);
labelStream << "Version " << QString::fromStdString(IVW_VERSION);
labelStream << "Version " << QString::fromStdString(toString(build::version));
painter->setPen(Qt::black);
painter->drawText(12, 326, versionLabel);
auto font = painter->font();
Expand Down
27 changes: 9 additions & 18 deletions apps/inviwo/packaging/packaging.cmake
Expand Up @@ -26,15 +26,9 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#################################################################################

# Don't use components, will not work with Drag & Drop, and we need controll all the
# component namnes which we can't for some of the externals like HDF5
set(CPACK_MONOLITHIC_INSTALL TRUE)
set(CMAKE_INSTALL_UCRT_LIBRARIES TRUE)
set(CMAKE_INSTALL_OPENMP_LIBRARIES TRUE)
if(IVW_OPENMP_ON)
set(CMAKE_INSTALL_OPENMP_LIBRARIES TRUE)
endif()
set(CMAKE_INSTALL_SYSTEM_RUNTIME_COMPONENT Application)
include (InstallRequiredSystemLibraries)

set(CPACK_PACKAGE_NAME "Inviwo")
Expand All @@ -45,9 +39,13 @@ set(CPACK_PACKAGE_VERSION_MINOR "${IVW_MINOR_VERSION}")
set(CPACK_PACKAGE_VERSION_PATCH "${IVW_PATCH_VERSION}")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${IVW_ROOT_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${IVW_ROOT_DIR}/LICENSE")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-v${IVW_VERSION}")


set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-v${IVW_VERSION}")
set(CPACK_MONOLITHIC_INSTALL OFF)
ivw_get_target_property_recursive(install_list inviwo INTERFACE_IVW_INSTALL_LIST OFF)
ivw_filter_install_list(LIST install_list REMOVE_COMPONENTS Development Testing)
list(TRANSFORM install_list REPLACE "\\|%\\|" ";")
set(CPACK_INSTALL_CMAKE_PROJECTS ${install_list})

if(WIN32)
# Need backslash for correct subdirectory paths with NSIS
Expand Down Expand Up @@ -103,15 +101,8 @@ else()
endif()
endif()

if(NOT APPLE)
install(DIRECTORY ${IVW_ROOT_DIR}/data/images DESTINATION data COMPONENT images)
install(DIRECTORY ${IVW_ROOT_DIR}/data/scripts DESTINATION data COMPONENT scripts)
install(DIRECTORY ${IVW_ROOT_DIR}/data/volumes DESTINATION data COMPONENT volumes)
install(DIRECTORY ${IVW_ROOT_DIR}/data/workspaces DESTINATION data COMPONENT workspaces)

install(DIRECTORY ${IVW_ROOT_DIR}/tests/images DESTINATION tests COMPONENT images)
install(DIRECTORY ${IVW_ROOT_DIR}/tests/volumes DESTINATION tests COMPONENT volumes)
endif()
install(DIRECTORY ${IVW_ROOT_DIR}/data/ DESTINATION ${IVW_RESOURCE_INSTALL_PREFIX}data COMPONENT Datasets)
install(DIRECTORY ${IVW_ROOT_DIR}/tests/ DESTINATION ${IVW_RESOURCE_INSTALL_PREFIX}tests COMPONENT Testing)

include(CPack)