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

Clean up CMake #23

Merged
merged 4 commits into from
Jun 20, 2024
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
13 changes: 5 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,20 @@ project(mcpp)

set(CMAKE_CXX_STANDARD 17)

set(PROJECT_SOURCE_DIR src)
set(MCPP_PUBLIC_INCLUDE_DIRECTORIES include/ )
set(MCPP_SRC_DIR src)
set(MCPP_INC_DIR include/mcpp)

# Testing
enable_testing()
add_subdirectory(test)
add_test(NAME local COMMAND local_tests)
add_test(NAME full COMMAND test_suite)

# Source files
file(GLOB_RECURSE MCPP_INCLUDE_FILES "include/*.h")
file(GLOB_RECURSE MCPP_SOURCE_FILES "src/*.cpp")
file(GLOB_RECURSE MCPP_INCLUDE_FILES ${MCPP_INC_DIR}/*.h)
file(GLOB_RECURSE MCPP_SOURCE_FILES ${MCPP_SRC_DIR}/*.cpp)

# Library build
add_library(${PROJECT_NAME} STATIC ${MCPP_INCLUDE_FILES} ${MCPP_SOURCE_FILES})

target_include_directories(${PROJECT_NAME} PUBLIC ${MCPP_PUBLIC_INCLUDE_DIRECTORIES})
add_library(${PROJECT_NAME} SHARED ${MCPP_INCLUDE_FILES} ${MCPP_SOURCE_FILES})

set_target_properties(${PROJECT_NAME}
PROPERTIES
Expand Down
5 changes: 5 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
add_executable(local_tests EXCLUDE_FROM_ALL local_tests.cpp)
add_executable(minecraft_tests EXCLUDE_FROM_ALL local_tests.cpp minecraft_tests.cpp)
add_executable(test_suite EXCLUDE_FROM_ALL local_tests.cpp minecraft_tests.cpp)

target_link_libraries(local_tests ${PROJECT_NAME})
target_link_libraries(minecraft_tests ${PROJECT_NAME})
target_link_libraries(test_suite ${PROJECT_NAME})

# Enable player tests for full test suite
set_property(TARGET test_suite PROPERTY COMPILE_DEFINITIONS PLAYER_TEST)
7 changes: 2 additions & 5 deletions test/minecraft_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
#include "../include/mcpp/mcpp.h"
#include "doctest.h"

// Set to 1 if testing with joined player on server
#define PLAYER_TEST 1

using namespace std::string_literals;
using namespace mcpp;

Expand Down Expand Up @@ -156,8 +153,8 @@ TEST_CASE("Test the main mcpp class") {
}

// Requires player joined to server, will throw serverside if player is not
// joined and hang execution
#if PLAYER_TEST
// joined
#ifdef PLAYER_TEST

TEST_CASE("Player operations") {
Coordinate testLoc(110, 110, 110);
Expand Down