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] ogs_add_library()-function #2881

Merged
merged 8 commits into from
Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions Applications/ApplicationsLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ get_source_files(SOURCES_APPLICATIONSLIB)
set(LIB_SOURCES ${SOURCES_APPLICATIONSLIB})

# Library
add_library(ApplicationsLib ${LIB_SOURCES})
if(BUILD_SHARED_LIBS)
install(TARGETS ApplicationsLib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
ogs_add_library(ApplicationsLib ${LIB_SOURCES})

target_link_libraries(ApplicationsLib
PUBLIC BaseLib GeoLib NumLib Processes logog
Expand All @@ -26,10 +23,6 @@ foreach(process ${ProcessesList})
endif()
endforeach()

if(OGS_USE_PCH)
cotire(ApplicationsLib)
endif()

if(OGS_USE_PYTHON)
target_link_libraries(ApplicationsLib PRIVATE pybind11::pybind11)
endif()
5 changes: 1 addition & 4 deletions Applications/CLI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if(OGS_USE_PYTHON)
# appropriate message should be presented. The note is kept for the case
# that the automatic detection does not work due to whatever reason.

add_library(ogs_embedded_python ogs_embedded_python.cpp)
ogs_add_library(ogs_embedded_python ogs_embedded_python.cpp)

# Performance warning from
# https://github.com/pybind/pybind11/blob/master/docs/compiling.rst: Since
Expand All @@ -57,9 +57,6 @@ if(OGS_USE_PYTHON)
# by the linker.
target_compile_definitions(ogs_embedded_python PRIVATE
OGS_BUILD_SHARED_LIBS)
install(TARGETS ogs_embedded_python
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})

endif()
endif()

Expand Down
9 changes: 1 addition & 8 deletions Applications/DataExplorer/Base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,8 @@ source_group("UI Files" REGULAR_EXPRESSION "\\w*\\.ui")
source_group("Moc Files" REGULAR_EXPRESSION "moc_.*")

# Create the library
add_library(QtBase ${SOURCES} ${HEADERS})
if(BUILD_SHARED_LIBS)
install(TARGETS QtBase LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
ogs_add_library(QtBase ${SOURCES} ${HEADERS})

target_link_libraries(QtBase Qt5::Widgets)

set_property(TARGET QtBase PROPERTY FOLDER "DataExplorer")

if(OGS_USE_PCH)
cotire(QtBase)
endif()
9 changes: 1 addition & 8 deletions Applications/DataExplorer/DataView/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,7 @@ if(GEOTIFF_FOUND)
include_directories(${GEOTIFF_INCLUDE_DIRS})
endif() # GEOTIFF_FOUND

add_library(QtDataView ${SOURCES} ${HEADERS} ${UIS})
if(BUILD_SHARED_LIBS)
install(TARGETS QtDataView LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
ogs_add_library(QtDataView ${SOURCES} ${HEADERS} ${UIS})

target_link_libraries(QtDataView
PUBLIC GeoLib
Expand All @@ -149,7 +146,3 @@ endif() # GEOTIFF_FOUND
add_autogen_include(QtDataView)

set_property(TARGET QtDataView PROPERTY FOLDER "DataExplorer")

if(OGS_USE_PCH)
cotire(QtDataView)
endif()
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ include_directories(${SOURCE_DIR_REL}/BaseLib
file(GLOB_RECURSE UIS CONFIGURE_DEPENDS *.ui)
source_group("UI Files" FILES ${UIS})

add_library(QtDiagramView ${SOURCES} ${HEADERS} ${UIS})
if(BUILD_SHARED_LIBS)
install(TARGETS QtDiagramView LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
ogs_add_library(QtDiagramView ${SOURCES} ${HEADERS} ${UIS})

target_link_libraries(QtDiagramView
PRIVATE BaseLib
Expand All @@ -45,7 +42,3 @@ target_link_libraries(QtDiagramView
add_autogen_include(QtDiagramView)

set_property(TARGET QtDiagramView PROPERTY FOLDER "DataExplorer")

if(OGS_USE_PCH)
cotire(QtDiagramView)
endif()
9 changes: 1 addition & 8 deletions Applications/DataExplorer/DataView/StratView/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
file(GLOB_RECURSE UI_FILES CONFIGURE_DEPENDS *.ui)
source_group("UI Files" FILES ${UI_FILES})

add_library(QtStratView ${SOURCES} ${HEADERS} ${UIS})
if(BUILD_SHARED_LIBS)
install(TARGETS QtStratView LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
ogs_add_library(QtStratView ${SOURCES} ${HEADERS} ${UIS})

target_link_libraries(QtStratView
PRIVATE BaseLib
Expand All @@ -27,7 +24,3 @@ target_link_libraries(QtStratView
add_autogen_include(QtStratView)

set_property(TARGET QtStratView PROPERTY FOLDER "DataExplorer")

if(OGS_USE_PCH)
cotire(QtStratView)
endif()
6 changes: 1 addition & 5 deletions Applications/DataExplorer/NetCdfDialog/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
add_library(NetCdfDialogLib NetCdfConfigureDialog.cpp NetCdfConfigureDialog.h)
if(BUILD_SHARED_LIBS)
install(TARGETS NetCdfConfigureDialog
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
ogs_add_library(NetCdfDialogLib NetCdfConfigureDialog.cpp NetCdfConfigureDialog.h)
target_link_libraries(NetCdfDialogLib
PUBLIC Qt5::Widgets
${NETCDF_LIBRARIES_CXX}
Expand Down
9 changes: 1 addition & 8 deletions Applications/DataExplorer/VtkVis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${GUI_SOURCE_DIR_REL}/DataView
${GUI_SOURCE_DIR_REL}/VtkModules/Qt)

add_library(VtkVis ${SOURCES} ${HEADERS} ${UIS})
if(BUILD_SHARED_LIBS)
install(TARGETS VtkVis LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
ogs_add_library(VtkVis ${SOURCES} ${HEADERS} ${UIS})

if(GEOTIFF_FOUND)
include_directories(${GEOTIFF_INCLUDE_DIRS})
Expand All @@ -145,7 +142,3 @@ endif()
set_property(TARGET VtkVis PROPERTY FOLDER "DataExplorer")

add_autogen_include(VtkVis)

if(OGS_USE_PCH)
cotire(VtkVis)
endif()
9 changes: 1 addition & 8 deletions Applications/DataHolderLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@
get_source_files(SOURCES_DataHolderLib)

# Library
add_library(DataHolderLib ${SOURCES_DataHolderLib})
if(BUILD_SHARED_LIBS)
install(TARGETS DataHolderLib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
ogs_add_library(DataHolderLib ${SOURCES_DataHolderLib})

target_link_libraries(DataHolderLib PUBLIC GeoLib MeshLib PRIVATE BaseLib logog)

if(OGS_USE_PCH)
cotire(DataHolderLib)
endif()
10 changes: 1 addition & 9 deletions Applications/FileIO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ endif()
include(${PROJECT_SOURCE_DIR}/scripts/cmake/OGSEnabledElements.cmake)

# Create the library
add_library(ApplicationsFileIO ${SOURCES})
if(BUILD_SHARED_LIBS)
install(TARGETS ApplicationsFileIO
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
ogs_add_library(ApplicationsFileIO ${SOURCES})
target_link_libraries(ApplicationsFileIO
PUBLIC BaseLib
DataHolderLib
Expand All @@ -49,10 +45,6 @@ if(OGS_BUILD_SWMM)
target_link_libraries(ApplicationsFileIO PRIVATE SwmmInterface)
endif()

if(OGS_USE_PCH)
cotire(ApplicationsFileIO)
endif()

configure_file(XmlIO/OpenGeoSysCND.xsd
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/OpenGeoSysCND.xsd COPYONLY)
configure_file(XmlIO/OpenGeoSysNum.xsd
Expand Down
9 changes: 1 addition & 8 deletions Applications/InSituLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@
get_source_files(SOURCES)

# Library
add_library(InSituLib ${SOURCES})
if(BUILD_SHARED_LIBS)
install(TARGETS InSituLib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
ogs_add_library(InSituLib ${SOURCES})

target_link_libraries(PUBLIC BaseLib PRIVATE MeshLib)

if(OGS_USE_PCH)
cotire(InSituLib)
endif()
10 changes: 1 addition & 9 deletions Applications/Utils/OGSFileConverter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
add_library(OGSFileConverterLib FileListDialog.h OGSFileConverter.h
ogs_add_library(OGSFileConverterLib FileListDialog.h OGSFileConverter.h
FileListDialog.cpp OGSFileConverter.cpp)
target_link_libraries(OGSFileConverterLib
PUBLIC ApplicationsFileIO MathLib QtBase ${VTK_LIBRARIES}
INTERFACE MeshLib)
if(BUILD_SHARED_LIBS)
install(TARGETS OGSFileConverterLib
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()

set_target_properties(OGSFileConverterLib PROPERTIES AUTOMOC TRUE AUTOUIC TRUE)

Expand All @@ -20,8 +16,4 @@ add_autogen_include(OGSFileConverterLib)
set_target_properties(OGSFileConverter OGSFileConverterLib
PROPERTIES FOLDER "Utilities")

if(OGS_USE_PCH)
cotire(OGSFileConverterLib)
endif()

install(TARGETS OGSFileConverter RUNTIME DESTINATION bin COMPONENT Utilities)
15 changes: 1 addition & 14 deletions BaseLib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,12 @@
get_source_files(SOURCES)
append_source_files(SOURCES IO)

append_source_files(SOURCES IO/XmlIO)

if(OGS_BUILD_GUI)
append_source_files(SOURCES IO/XmlIO/Qt)
endif()

# Create the library
add_library(BaseLib ${SOURCES})
if(BUILD_SHARED_LIBS)
install(TARGETS BaseLib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()

include(GenerateExportHeader)
generate_export_header(BaseLib)
target_include_directories(BaseLib PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
ogs_add_library(BaseLib ${SOURCES})

target_link_libraries(BaseLib PUBLIC logog Boost::boost)

Expand All @@ -26,7 +17,3 @@ endif()
if(OGS_BUILD_GUI)
target_link_libraries(BaseLib PUBLIC Qt5::Xml Qt5::XmlPatterns)
endif()

if(OGS_USE_PCH)
cotire(BaseLib)
endif()
9 changes: 1 addition & 8 deletions ChemistryLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,11 @@ append_source_files(SOURCES PhreeqcKernelData)
append_source_files(SOURCES Common)

# Create the library
add_library(ChemistryLib ${SOURCES})
if(BUILD_SHARED_LIBS)
install(TARGETS ChemistryLib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
ogs_add_library(ChemistryLib ${SOURCES})

include(GenerateExportHeader)
generate_export_header(ChemistryLib)

target_link_libraries(ChemistryLib PUBLIC iphreeqc PRIVATE NumLib)

set_target_properties(ChemistryLib PROPERTIES CXX_STANDARD 14)

if(OGS_USE_PCH)
cotire(ChemistryLib)
endif()
9 changes: 1 addition & 8 deletions GeoLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,14 @@ if(OGS_BUILD_GUI)
endif()

# Create the library
add_library(GeoLib ${SOURCES})
if(BUILD_SHARED_LIBS)
install(TARGETS GeoLib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
ogs_add_library(GeoLib ${SOURCES})

target_link_libraries(GeoLib PUBLIC BaseLib MathLib logog PRIVATE tet)

if(OGS_BUILD_GUI)
target_link_libraries(GeoLib PUBLIC Qt5::Xml Qt5::XmlPatterns)
endif()

if(OGS_USE_PCH)
cotire(GeoLib)
endif()

configure_file(IO/XmlIO/OpenGeoSysGLI.xsd
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/OpenGeoSysGLI.xsd COPYONLY)
configure_file(IO/XmlIO/OpenGeoSysSTN.xsd
Expand Down
7 changes: 1 addition & 6 deletions InfoLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,8 @@ foreach(lib Git CMake Test)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${lib}Info.cpp.in
${CMAKE_CURRENT_BINARY_DIR}/${lib}Info.cpp @ONLY)

add_library(${lib}InfoLib ${CMAKE_CURRENT_BINARY_DIR}/${lib}Info.cpp
ogs_add_library(${lib}InfoLib ${CMAKE_CURRENT_BINARY_DIR}/${lib}Info.cpp
${lib}Info.h)

include(GenerateExportHeader)
generate_export_header(${lib}InfoLib)
target_include_directories(${lib}InfoLib PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
if(BUILD_SHARED_LIBS)
install(TARGETS ${lib}InfoLib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
endforeach(lib)
9 changes: 1 addition & 8 deletions MaterialLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ if(OGS_USE_MFRONT)
add_subdirectory(SolidModels/MFront)
endif()

add_library(MaterialLib ${SOURCES})
if(BUILD_SHARED_LIBS)
install(TARGETS MaterialLib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
ogs_add_library(MaterialLib ${SOURCES})

include(GenerateExportHeader)
generate_export_header(MaterialLib)
Expand All @@ -48,7 +45,3 @@ target_link_libraries(MaterialLib PRIVATE MathLib MeshLib ParameterLib)
if(OGS_USE_MFRONT)
target_link_libraries(MaterialLib PUBLIC MaterialLib_SolidModels_MFront)
endif()

if(OGS_USE_PCH)
cotire(MaterialLib)
endif()
7 changes: 1 addition & 6 deletions MaterialLib/SolidModels/MFront/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ set(SOURCES CreateMFront.cpp CreateMFront.h)

list(APPEND SOURCES MFront.cpp MFront.h)

add_library(MaterialLib_SolidModels_MFront ${SOURCES})

if(BUILD_SHARED_LIBS)
install(TARGETS MaterialLib_SolidModels_MFront
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
ogs_add_library(MaterialLib_SolidModels_MFront ${SOURCES})

target_link_libraries(MaterialLib_SolidModels_MFront
PUBLIC BaseLib NumLib logog OgsMFrontBehaviour
Expand Down
12 changes: 1 addition & 11 deletions MathLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,7 @@ if(OGS_USE_PETSC)
endif()

# Create the library
add_library(MathLib ${SOURCES})
if(BUILD_SHARED_LIBS)
install(TARGETS MathLib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()

include(GenerateExportHeader)
generate_export_header(MathLib)
ogs_add_library(MathLib ${SOURCES})
target_include_directories(MathLib PUBLIC ${CMAKE_CURRENT_BINARY_DIR})

set_target_properties(MathLib PROPERTIES LINKER_LANGUAGE CXX)
Expand Down Expand Up @@ -59,7 +53,3 @@ if(OGS_USE_PETSC)
target_include_directories(MathLib PUBLIC ${PETSC_INCLUDE_DIRS})
target_link_libraries(MathLib PUBLIC ${PETSC_LIBRARIES})
endif()

if(OGS_USE_PCH)
cotire(MathLib)
endif()
9 changes: 1 addition & 8 deletions MeshGeoToolsLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,8 @@
get_source_files(SOURCES)

# Create the library
add_library(MeshGeoToolsLib ${SOURCES})
if(BUILD_SHARED_LIBS)
install(TARGETS MeshGeoToolsLib LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
ogs_add_library(MeshGeoToolsLib ${SOURCES})

target_link_libraries(MeshGeoToolsLib
PUBLIC GeoLib MathLib
PRIVATE BaseLib MeshLib logog)

if(OGS_USE_PCH)
cotire(MeshGeoToolsLib)
endif()
Loading