Skip to content

Commit

Permalink
Refactor CMake stuff after mo2-cmake updates for sources management.
Browse files Browse the repository at this point in the history
  • Loading branch information
Holt59 committed Jul 13, 2024
1 parent e94503c commit 8f0431d
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 57 deletions.
161 changes: 105 additions & 56 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,7 @@ find_package(Qt6 CONFIG REQUIRED COMPONENTS Network Qml Quick QuickWidgets Widge
find_package(spdlog CONFIG REQUIRED)
find_package(Boost REQUIRED CONFIG COMPONENTS thread)

file(GLOB_RECURSE uibase_headers RELATIVE ${CMAKE_CURRENT_LIST_DIR} "${CMAKE_CURRENT_LIST_DIR}/../include/**/*.h")

add_library(uibase SHARED)
mo2_configure_target(uibase WARNINGS ON EXTERNAL_WARNINGS ON)
target_sources(uibase
PUBLIC
FILE_SET HEADERS
BASE_DIRS ${CMAKE_CURRENT_LIST_DIR}/../include
FILES ${uibase_headers}
)

set_target_properties(uibase PROPERTIES DEBUG_POSTFIX d)

# TODO: remove this after fixing UIBase #include<> directives
target_include_directories(uibase PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/uibase>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/uibase/game_features>
)

add_library(mo2::uibase ALIAS uibase)

target_compile_definitions(uibase PRIVATE -DUIBASE_EXPORT SPDLOG_USE_STD_FORMAT)

target_link_libraries(uibase
PUBLIC Qt6::Widgets Qt6::Network Qt6::QuickWidgets
PRIVATE
Boost::headers Boost::thread spdlog::spdlog_header_only
Qt6::Qml Qt6::Quick Version)

# installation
install(TARGETS uibase EXPORT uibaseTargets FILE_SET HEADERS)
install(FILES $<TARGET_PDB_FILE:uibase> DESTINATION pdb)
install(EXPORT uibaseTargets
FILE mo2-uibase-targets.cmake
NAMESPACE mo2::
DESTINATION lib/cmake/mo2-uibase
)

# filters
source_group(src FILES
set(root_headers
../include/uibase/delayedfilewriter.h
../include/uibase/diagnosisreport.h
../include/uibase/dllimport.h
Expand Down Expand Up @@ -71,15 +32,13 @@ source_group(src FILES
../include/uibase/utility.h
../include/uibase/versioninfo.h
)

source_group(src/interfaces FILES
set(interface_headers
../include/uibase/ifiletree.h
../include/uibase/iinstallationmanager.h
../include/uibase/imodinterface.h
../include/uibase/imodlist.h
../include/uibase/imodrepositorybridge.h
../include/uibase/imoinfo.h
../include/uibase/installationtester.h
../include/uibase/iplugin.h
../include/uibase/iplugindiagnose.h
../include/uibase/ipluginfilemapper.h
Expand All @@ -96,23 +55,13 @@ source_group(src/interfaces FILES
../include/uibase/iprofile.h
../include/uibase/isavegame.h
../include/uibase/isavegameinfowidget.h

ifiletree.cpp
imodrepositorybridge.cpp
imoinfo.cpp
iplugininstaller.cpp
)

source_group(src/tutorials FILES
set(tutorial_headers
../include/uibase/tutorabledialog.h
../include/uibase/tutorialcontrol.h
../include/uibase/tutorialmanager.h
tutorabledialog.cpp
tutorialcontrol.cpp
tutorialmanager.cpp
)

source_group(src/widgets FILES
set(widget_headers
../include/uibase/expanderwidget.h
../include/uibase/filterwidget.h
../include/uibase/finddialog.h
Expand All @@ -123,7 +72,80 @@ source_group(src/widgets FILES
../include/uibase/taskprogressmanager.h
../include/uibase/textviewer.h
../include/uibase/widgetutility.h
)

add_library(uibase SHARED)
mo2_configure_target(uibase NO_SOURCES WARNINGS ON EXTERNAL_WARNINGS ON)
mo2_default_source_group()

target_sources(uibase
PRIVATE
finddialog.ui
questionboxmemory.ui
taskdialog.ui
textviewer.ui

version.rc

${root_headers}
pch.h

PUBLIC
FILE_SET HEADERS
BASE_DIRS ${CMAKE_CURRENT_LIST_DIR}/../include
FILES ${root_headers} ${interface_headers} ${tutorial_headers} ${widget_headers}
)

mo2_target_sources(uibase
FOLDER src
PRIVATE
${root_headers}
delayedfilewriter.cpp
diagnosisreport.cpp
errorcodes.cpp
eventfilter.cpp
executableinfo.cpp
filesystemutilities.cpp
guessedvalue.cpp
json.cpp
log.cpp
modrepositoryfileinfo.cpp
nxmurl.cpp
pch.cpp
pluginrequirements.cpp
pluginsetting.cpp
registry.cpp
report.cpp
safewritefile.cpp
scopeguard.cpp
steamutility.cpp
utility.cpp
versioninfo.cpp
)

mo2_target_sources(uibase
FOLDER src/interfaces
PRIVATE
${interface_headers}
ifiletree.cpp
imodrepositorybridge.cpp
imoinfo.cpp
iplugininstaller.cpp
)

mo2_target_sources(uibase
FOLDER src/tutorials
PRIVATE
${tutorial_headers}
tutorabledialog.cpp
tutorialcontrol.cpp
tutorialmanager.cpp
)

mo2_target_sources(uibase
FOLDER src/widgets
PRIVATE
${widget_headers}
expanderwidget.cpp
finddialog.cpp
lineeditclear.cpp
Expand All @@ -133,7 +155,7 @@ source_group(src/widgets FILES
taskprogressmanager.cpp
textviewer.cpp
widgetutility.cpp
filterwidget.cpp
filterwidget.cpp
)

get_target_property(game_features uibase HEADER_SET_HEADERS)
Expand All @@ -143,3 +165,30 @@ source_group(src/game_features FILES ${game_features})
get_target_property(formatters uibase HEADER_SET_HEADERS)
list(FILTER formatters INCLUDE REGEX ".*formatters.*")
source_group(src/formatters FILES ${formatters})

set_target_properties(uibase PROPERTIES DEBUG_POSTFIX d)

# TODO: remove this after fixing UIBase #include<> directives
target_include_directories(uibase PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/uibase>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include/uibase/game_features>
)

add_library(mo2::uibase ALIAS uibase)

target_compile_definitions(uibase PRIVATE -DUIBASE_EXPORT SPDLOG_USE_STD_FORMAT)

target_link_libraries(uibase
PUBLIC Qt6::Widgets Qt6::Network Qt6::QuickWidgets
PRIVATE
Boost::headers Boost::thread spdlog::spdlog_header_only
Qt6::Qml Qt6::Quick Version)

# installation
install(TARGETS uibase EXPORT uibaseTargets FILE_SET HEADERS)
install(FILES $<TARGET_PDB_FILE:uibase> DESTINATION pdb)
install(EXPORT uibaseTargets
FILE mo2-uibase-targets.cmake
NAMESPACE mo2::
DESTINATION lib/cmake/mo2-uibase
)
2 changes: 1 addition & 1 deletion vcpkg-configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{
"kind": "git",
"repository": "https://github.com/ModOrganizer2/vcpkg-registry",
"baseline": "27d8adbfe9e4ce88a875be3a45fadab69869eb60",
"baseline": "09c389ef37bcec89b28f13105be959fecf4f3975",
"packages": ["mo2-cmake", "spdlog"]
}
]
Expand Down

0 comments on commit 8f0431d

Please sign in to comment.