From 2d2a8a299d72a8dccb6d50fe2eb7a381e816496f Mon Sep 17 00:00:00 2001 From: Lars Bilke <lars.bilke@ufz.de> Date: Fri, 2 Apr 2021 21:51:27 +0200 Subject: [PATCH] [CMake] Fixed gui shared build. Will also fix container job. --- Applications/DataExplorer/DataView/CMakeLists.txt | 2 +- Applications/DataExplorer/VtkVis/CMakeLists.txt | 2 +- scripts/cmake/Functions.cmake | 12 ++++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Applications/DataExplorer/DataView/CMakeLists.txt b/Applications/DataExplorer/DataView/CMakeLists.txt index 4b92840af31..0d528722995 100644 --- a/Applications/DataExplorer/DataView/CMakeLists.txt +++ b/Applications/DataExplorer/DataView/CMakeLists.txt @@ -131,7 +131,7 @@ if(GEOTIFF_FOUND) include_directories(${GEOTIFF_INCLUDE_DIRS}) endif() # GEOTIFF_FOUND -ogs_add_library(QtDataView ${SOURCES} ${HEADERS} ${UIS}) +ogs_add_library(QtDataView STATIC ${SOURCES} ${HEADERS} ${UIS}) target_link_libraries( QtDataView diff --git a/Applications/DataExplorer/VtkVis/CMakeLists.txt b/Applications/DataExplorer/VtkVis/CMakeLists.txt index 566db8f03b9..5fe7c6cd2ab 100644 --- a/Applications/DataExplorer/VtkVis/CMakeLists.txt +++ b/Applications/DataExplorer/VtkVis/CMakeLists.txt @@ -132,7 +132,7 @@ include_directories( ${GUI_SOURCE_DIR_REL}/VtkModules/Qt ) -ogs_add_library(VtkVis ${SOURCES} ${HEADERS} ${UIS}) +ogs_add_library(VtkVis STATIC ${SOURCES} ${HEADERS} ${UIS}) if(GEOTIFF_FOUND) target_compile_definitions(VtkVis PRIVATE GEOTIFF_FOUND) diff --git a/scripts/cmake/Functions.cmake b/scripts/cmake/Functions.cmake index 7d78cbcf648..6dd9ee57615 100644 --- a/scripts/cmake/Functions.cmake +++ b/scripts/cmake/Functions.cmake @@ -83,12 +83,20 @@ endfunction() # Replacement for add_library() for ogs targets function(ogs_add_library targetName) - foreach(file ${ARGN}) + set(options STATIC SHARED) + cmake_parse_arguments(ogs_add_library "${options}" "" "" ${ARGN}) + + foreach(file ${ogs_add_library_UNPARSED_ARGUMENTS}) get_filename_component(file_path ${file} REALPATH) list(APPEND files ${file_path}) endforeach() - add_library(${targetName} ${files}) + if(ogs_add_library_STATIC) + set(TYPE STATIC) + elseif(ogs_add_library_SHARED) + set(TYPE SHARED) + endif() + add_library(${targetName} ${TYPE} ${files}) target_compile_options( ${targetName} PRIVATE # OR does not work with cotire -- GitLab