Skip to content

Commit

Permalink
simplify cmake and fix linking to TombRaiderLinuxLauncher
Browse files Browse the repository at this point in the history
  • Loading branch information
noisecode3 committed Dec 11, 2024
1 parent 4ff14eb commit 1e0e74c
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 91 deletions.
82 changes: 28 additions & 54 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ find_package(Boost REQUIRED COMPONENTS system filesystem)
find_package(OpenSSL REQUIRED)

if(NOT EXISTS "${CMAKE_SOURCE_DIR}/libs/miniz/CMakeLists.txt")
message(STATUS "Submodule 'libs/miniz' not found. Initializing submodules...")
message(STATUS "Submodule 'libs/miniz' not found. Updating submodules...")
execute_process(
COMMAND git submodule update --init --recursive
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
Expand All @@ -32,25 +32,8 @@ endif()
add_subdirectory(libs/miniz)

set(SOURCES
src/main.cpp
src/binary.h
src/gameTree.h
src/staticData.h
src/Network.h
src/Network.cpp
src/Controller.h
src/Controller.cpp
src/FileManager.h
src/FileManager.cpp
src/Model.h
src/Model.cpp
src/Data.h
src/Data.cpp
)

set(TEST_SOURCES
test/main.cpp
test/test.h
src/main.cpp
src/binary.h
src/gameTree.h
src/staticData.h
Expand All @@ -64,58 +47,49 @@ set(TEST_SOURCES
src/Model.cpp
src/Data.h
src/Data.cpp
)
src/TombRaiderLinuxLauncher.h
src/TombRaiderLinuxLauncher.cpp
src/TombRaiderLinuxLauncher.ui
src/resources.qrc)

if(TEST)
enable_testing()
set(PROJECT_NAME_POST "${PROJECT_NAME}Test")
add_executable(${PROJECT_NAME_POST} ${TEST_SOURCES})
target_link_libraries(${PROJECT_NAME_POST} PUBLIC
Qt5::Core
Qt5::Gui
Qt5::Test
Qt5::Widgets
Qt5::WebEngineWidgets
Qt5::Sql
miniz
${CURL_LIBRARY}
OpenSSL::SSL
Boost::system
Boost::filesystem
)
add_test(NAME ${PROJECT_NAME_POST} COMMAND ${PROJECT_NAME_POST})
enable_testing(ON)
add_executable(${PROJECT_NAME}Test ${SOURCES})
add_test(NAME ${PROJECT_NAME}Test COMMAND ${PROJECT_NAME}Test)
else()
set(PROJECT_NAME_POST "${PROJECT_NAME}")
add_executable(${PROJECT_NAME_POST} ${SOURCES})
target_link_libraries(${PROJECT_NAME_POST} PUBLIC
Qt5::Core
Qt5::Gui
Qt5::Widgets
Qt5::WebEngineWidgets
Qt5::Sql
miniz
${CURL_LIBRARY}
OpenSSL::SSL
Boost::system
Boost::filesystem
)
enable_testing(OFF)
add_executable(${PROJECT_NAME} ${SOURCES})
endif()

target_include_directories(${PROJECT_NAME_POST} PRIVATE
target_link_libraries(${PROJECT_NAME} PUBLIC
Qt5::Core
Qt5::Test
Qt5::Gui
Qt5::Widgets
Qt5::WebEngineWidgets
Qt5::Sql
miniz
${CURL_LIBRARY}
OpenSSL::SSL
Boost::system
Boost::filesystem
)

target_include_directories(${PROJECT_NAME} PRIVATE
${CURL_INCLUDE_DIR}
${Boost_INCLUDE_DIRS}
libs/miniz
src
test
)

set_target_properties(${PROJECT_NAME_POST} PROPERTIES
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED ON
)

if(NOT TEST)
install(TARGETS ${PROJECT_NAME_POST}
install(TARGETS ${PROJECT_NAME}
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
)

Expand Down
30 changes: 21 additions & 9 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,31 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "TombRaiderLinuxLauncher.h"
#ifdef TEST
#include <QtTest/QtTest>
#include "binary.h"
#include "test.h"

/**
*
*/
int main(int argc, char *argv[]) {
if (argc == 3 && strcmp(argv[1], "-w") == 0) {
widescreen_set(argv[2]);
} else {
TestTombRaiderLinuxLauncher test;
return QTest::qExec(&test, argc, argv);
}
}
#else
#include "TombRaiderLinuxLauncher.h"
#include <QApplication>


/**
*
*/
int main(int argc, char *argv[])
{
int main(int argc, char *argv[]) {
QApplication a(argc, argv);
QApplication::setOrganizationName("TombRaiderLinuxLauncher");
QApplication::setApplicationName("TombRaiderLinuxLauncher");
Expand All @@ -32,14 +47,11 @@ int main(int argc, char *argv[])
TombRaiderLinuxLauncher w;

QStringList arguments = a.arguments();
if (arguments.contains("--fullscreen"))
{
if (arguments.contains("--fullscreen")) {
w.showFullScreen();
}
else
{
} else {
w.show();
}

return a.exec();
}
#endif
28 changes: 0 additions & 28 deletions test/main.cpp

This file was deleted.

0 comments on commit 1e0e74c

Please sign in to comment.