From f3630ae3a5a285cddec7030193e3ddcc6295122d Mon Sep 17 00:00:00 2001 From: Vincent Date: Tue, 30 Apr 2024 10:48:02 +0100 Subject: [PATCH] feat: simplify CMakeLists.txt --- CMakeLists.txt | 52 +------------------------------------------------- 1 file changed, 1 insertion(+), 51 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 53d3259..377b6a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,64 +5,14 @@ project(endstone_example_plugin CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) - -# =============== -# Compiler Check -# =============== -if (WIN32) - if (NOT MSVC) - message(FATAL_ERROR "MSVC is required on Windows.") - endif () - add_compile_definitions(_ITERATOR_DEBUG_LEVEL=0) -elseif (UNIX) - if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang") - message(FATAL_ERROR "Clang is required on Linux.") - endif () - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -fPIC") - link_libraries(-static-libgcc -static-libstdc++ libc++.a libc++abi.a) -else () - message(FATAL_ERROR "${CMAKE_SYSTEM_NAME} (${CMAKE_SYSTEM_PROCESSOR}) is not supported") -endif () - - -# =============== -# Dependencies -# =============== include(FetchContent) -FetchContent_Declare( - fmt - GIT_REPOSITORY https://github.com/fmtlib/fmt.git - GIT_TAG 10.2.1 -) -FetchContent_MakeAvailable(fmt) - - -# =============== -# Endstone API -# =============== FetchContent_Declare( endstone GIT_REPOSITORY https://github.com/EndstoneMC/endstone.git GIT_TAG main # or set to a specific version tag ) -FetchContent_GetProperties(endstone) -if (NOT endstone_POPULATED) - FetchContent_Populate(endstone) -endif () -add_library(endstone_headers INTERFACE) -add_library(endstone::headers ALIAS endstone_headers) -target_include_directories(endstone_headers INTERFACE ${endstone_SOURCE_DIR}/include) -target_link_libraries(endstone_headers INTERFACE fmt::fmt) +FetchContent_MakeAvailable(endstone) - -# =============== -# Build -# =============== add_library(${PROJECT_NAME} SHARED src/example_plugin.cpp) target_include_directories(${PROJECT_NAME} PUBLIC include) target_link_libraries(${PROJECT_NAME} PRIVATE endstone::headers) - -# =============== -# Install -# =============== -install(TARGETS ${PROJECT_NAME})