Skip to content

Commit 1e0e74c

Browse files
committed
simplify cmake and fix linking to TombRaiderLinuxLauncher
1 parent 4ff14eb commit 1e0e74c

File tree

3 files changed

+49
-91
lines changed

3 files changed

+49
-91
lines changed

CMakeLists.txt

Lines changed: 28 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ find_package(Boost REQUIRED COMPONENTS system filesystem)
2222
find_package(OpenSSL REQUIRED)
2323

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

3434
set(SOURCES
35-
src/main.cpp
36-
src/binary.h
37-
src/gameTree.h
38-
src/staticData.h
39-
src/Network.h
40-
src/Network.cpp
41-
src/Controller.h
42-
src/Controller.cpp
43-
src/FileManager.h
44-
src/FileManager.cpp
45-
src/Model.h
46-
src/Model.cpp
47-
src/Data.h
48-
src/Data.cpp
49-
)
50-
51-
set(TEST_SOURCES
52-
test/main.cpp
5335
test/test.h
36+
src/main.cpp
5437
src/binary.h
5538
src/gameTree.h
5639
src/staticData.h
@@ -64,58 +47,49 @@ set(TEST_SOURCES
6447
src/Model.cpp
6548
src/Data.h
6649
src/Data.cpp
67-
)
50+
src/TombRaiderLinuxLauncher.h
51+
src/TombRaiderLinuxLauncher.cpp
52+
src/TombRaiderLinuxLauncher.ui
53+
src/resources.qrc)
6854

6955
if(TEST)
70-
enable_testing()
71-
set(PROJECT_NAME_POST "${PROJECT_NAME}Test")
72-
add_executable(${PROJECT_NAME_POST} ${TEST_SOURCES})
73-
target_link_libraries(${PROJECT_NAME_POST} PUBLIC
74-
Qt5::Core
75-
Qt5::Gui
76-
Qt5::Test
77-
Qt5::Widgets
78-
Qt5::WebEngineWidgets
79-
Qt5::Sql
80-
miniz
81-
${CURL_LIBRARY}
82-
OpenSSL::SSL
83-
Boost::system
84-
Boost::filesystem
85-
)
86-
add_test(NAME ${PROJECT_NAME_POST} COMMAND ${PROJECT_NAME_POST})
56+
enable_testing(ON)
57+
add_executable(${PROJECT_NAME}Test ${SOURCES})
58+
add_test(NAME ${PROJECT_NAME}Test COMMAND ${PROJECT_NAME}Test)
8759
else()
88-
set(PROJECT_NAME_POST "${PROJECT_NAME}")
89-
add_executable(${PROJECT_NAME_POST} ${SOURCES})
90-
target_link_libraries(${PROJECT_NAME_POST} PUBLIC
91-
Qt5::Core
92-
Qt5::Gui
93-
Qt5::Widgets
94-
Qt5::WebEngineWidgets
95-
Qt5::Sql
96-
miniz
97-
${CURL_LIBRARY}
98-
OpenSSL::SSL
99-
Boost::system
100-
Boost::filesystem
101-
)
60+
enable_testing(OFF)
61+
add_executable(${PROJECT_NAME} ${SOURCES})
10262
endif()
10363

104-
target_include_directories(${PROJECT_NAME_POST} PRIVATE
64+
target_link_libraries(${PROJECT_NAME} PUBLIC
65+
Qt5::Core
66+
Qt5::Test
67+
Qt5::Gui
68+
Qt5::Widgets
69+
Qt5::WebEngineWidgets
70+
Qt5::Sql
71+
miniz
72+
${CURL_LIBRARY}
73+
OpenSSL::SSL
74+
Boost::system
75+
Boost::filesystem
76+
)
77+
78+
target_include_directories(${PROJECT_NAME} PRIVATE
10579
${CURL_INCLUDE_DIR}
10680
${Boost_INCLUDE_DIRS}
10781
libs/miniz
10882
src
10983
test
11084
)
11185

112-
set_target_properties(${PROJECT_NAME_POST} PROPERTIES
86+
set_target_properties(${PROJECT_NAME} PROPERTIES
11387
CXX_STANDARD 17
11488
CXX_STANDARD_REQUIRED ON
11589
)
11690

11791
if(NOT TEST)
118-
install(TARGETS ${PROJECT_NAME_POST}
92+
install(TARGETS ${PROJECT_NAME}
11993
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
12094
)
12195

src/main.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,31 @@
1414
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1515
*/
1616

17-
#include "TombRaiderLinuxLauncher.h"
17+
#ifdef TEST
18+
#include <QtTest/QtTest>
19+
#include "binary.h"
20+
#include "test.h"
1821

22+
/**
23+
*
24+
*/
25+
int main(int argc, char *argv[]) {
26+
if (argc == 3 && strcmp(argv[1], "-w") == 0) {
27+
widescreen_set(argv[2]);
28+
} else {
29+
TestTombRaiderLinuxLauncher test;
30+
return QTest::qExec(&test, argc, argv);
31+
}
32+
}
33+
#else
34+
#include "TombRaiderLinuxLauncher.h"
1935
#include <QApplication>
2036

2137

2238
/**
2339
*
2440
*/
25-
int main(int argc, char *argv[])
26-
{
41+
int main(int argc, char *argv[]) {
2742
QApplication a(argc, argv);
2843
QApplication::setOrganizationName("TombRaiderLinuxLauncher");
2944
QApplication::setApplicationName("TombRaiderLinuxLauncher");
@@ -32,14 +47,11 @@ int main(int argc, char *argv[])
3247
TombRaiderLinuxLauncher w;
3348

3449
QStringList arguments = a.arguments();
35-
if (arguments.contains("--fullscreen"))
36-
{
50+
if (arguments.contains("--fullscreen")) {
3751
w.showFullScreen();
38-
}
39-
else
40-
{
52+
} else {
4153
w.show();
4254
}
43-
4455
return a.exec();
4556
}
57+
#endif

test/main.cpp

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)