-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat, ci, build: library no longer header-only. Windows CIs now added…
…, Project is now packagable. (#8)
- Loading branch information
1 parent
c020fb9
commit d888ea8
Showing
16 changed files
with
742 additions
and
491 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,76 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
|
||
option(BUILD_TESTS "Build the test program" ON) | ||
option(BUILD_SHARED_LIBS "Build shared libraries" ON) | ||
|
||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
add_compile_definitions(RCONPP_BUILD) | ||
|
||
set(RCONPP_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) | ||
|
||
project(rconpp | ||
VERSION 0.1.0 | ||
VERSION 0.5.0 | ||
LANGUAGES CXX | ||
HOMEPAGE_URL "https://github.com/Jaskowicz1/rconpp" | ||
DESCRIPTION "A modern Source-RCON library for C++" | ||
) | ||
|
||
include(GNUInstallDirs) | ||
if(NOT MSVC) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") | ||
endif() | ||
|
||
add_library(rconpp INTERFACE) | ||
if(UNIX OR MSYS) | ||
find_program(LDCONFIG_EXECUTABLE "ldconfig") | ||
endif() | ||
|
||
file(GLOB rconpp_src "src/rconpp/*.cpp" "src/rconpp/*.rc") | ||
|
||
if(BUILD_SHARED_LIBS) | ||
add_library(rconpp SHARED ${rconpp_src}) | ||
else() | ||
add_library(rconpp STATIC ${rconpp_src}) | ||
endif() | ||
|
||
target_include_directories(rconpp INTERFACE include/rconpp/rcon.h) | ||
target_include_directories(rconpp PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/rconpp> | ||
) | ||
|
||
set_target_properties(rconpp PROPERTIES | ||
VERSION ${CMAKE_PROJECT_VERSION} | ||
SOVERSION ${CMAKE_PROJECT_VERSION} | ||
POSITION_INDEPENDENT_CODE true | ||
LINKER_LANGUAGE CXX | ||
) | ||
|
||
if(NOT MSVC) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") | ||
endif() | ||
target_compile_features(rconpp PRIVATE cxx_std_17) | ||
target_compile_features(rconpp PRIVATE cxx_constexpr) | ||
target_compile_features(rconpp PRIVATE cxx_lambdas) | ||
|
||
if(BUILD_TESTS) | ||
add_executable(unittest "unittest/test.cpp") | ||
target_compile_features(unittest PRIVATE cxx_std_17) | ||
target_link_directories(unittest PRIVATE rconpp) | ||
target_link_libraries(unittest PUBLIC rconpp) | ||
enable_testing() | ||
add_test( | ||
NAME unittest | ||
COMMAND unittest | ||
) | ||
endif() | ||
|
||
if(NOT WIN32) | ||
include(GNUInstallDirs) | ||
install(TARGETS rconpp LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) | ||
message("Library install directory at ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") | ||
install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
message("Include files install directory at ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}") | ||
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -DRUN_LDCONFIG=${RUN_LDCONFIG} -DLDCONFIG_EXECUTABLE=${LDCONFIG_EXECUTABLE} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/PostInstall.cmake)") | ||
|
||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/rconpp.pc.in" "${CMAKE_BINARY_DIR}/rconpp.pc" @ONLY) | ||
install(FILES "${CMAKE_BINARY_DIR}/rconpp.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") | ||
endif() | ||
|
||
# Setup information for packaging and distribution | ||
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/CPackSetup.cmake") | ||
|
||
# CPack initialization for distribution | ||
include(CPack) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
include(GNUInstallDirs) | ||
set(RCONPP_EXPORT_NAME rconpp) | ||
set(RCONPP_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${RCONPP_EXPORT_NAME}) | ||
set(RCONPP_VERSION_FILE ${PROJECT_BINARY_DIR}/${RCONPP_EXPORT_NAME}-config-version.cmake) | ||
|
||
# The three lines below are only used for windows builds | ||
set(RCONPP_VERSIONED ${RCONPP_EXPORT_NAME}-1.0) | ||
set(RCONPP_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}/${RCONPP_VERSIONED}) | ||
set(RCONPP_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}/${RCONPP_VERSIONED}) | ||
|
||
|
||
## Pack the binary output | ||
if (WIN32) | ||
install(TARGETS rconpp | ||
EXPORT ${RCONPP_EXPORT_NAME} | ||
LIBRARY DESTINATION ${RCONPP_INSTALL_LIBRARY_DIR} | ||
ARCHIVE DESTINATION ${RCONPP_INSTALL_LIBRARY_DIR} | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
INCLUDES DESTINATION ${RCONPP_INSTALL_INCLUDE_DIR}) | ||
install(DIRECTORY "${RCONPP_ROOT_PATH}/include/" DESTINATION "${RCONPP_INSTALL_INCLUDE_DIR}") | ||
else() | ||
install(TARGETS rconpp | ||
EXPORT ${RCONPP_EXPORT_NAME} | ||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBRARY_DIR} | ||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBRARY_DIR} | ||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} | ||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDE_DIR}) | ||
endif() | ||
|
||
# Prepare information for packaging into .zip, .deb, .rpm | ||
## Project installation metadata | ||
set(CPACK_PACKAGE_NAME librconpp) | ||
set(CPACK_PACKAGE_VENDOR "Archie Jaskowicz") # Maker of the application | ||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A modern Source RCON library for C++") | ||
set(CPACK_PACKAGE_DESCRIPTION "A modern Source RCON library for C++") | ||
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/Jaskowicz1/rconpp") | ||
set(CPACK_FREEBSD_PACKAGE_MAINTAINER "[email protected]") | ||
set(CPACK_FREEBSD_PACKAGE_ORIGIN "misc/librconpp") | ||
set(CPACK_RPM_PACKAGE_LICENSE "Apache 2.0") | ||
set(CPACK_PACKAGE_CONTACT "https://jaskowicz.xyz/contact") | ||
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "A modern Source RCON library for C++") | ||
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") | ||
set(CPACK_DEBIAN_PACKAGE_SECTION "libs") | ||
set(CPACK_PACKAGE_VERSION_MAJOR 1) | ||
set(CPACK_PACKAGE_VERSION_MINOR 0) | ||
set(CPACK_PACKAGE_VERSION_PATCH 0) | ||
|
||
## Select generated based on what operating system | ||
if(WIN32) | ||
set(CPACK_GENERATOR ZIP) | ||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") | ||
set(CPACK_GENERATOR "DEB") | ||
else() | ||
set(CPACK_GENERATOR "TBZ2") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
if(LDCONFIG_EXECUTABLE) | ||
message(STATUS "Running ldconfig") | ||
|
||
execute_process(COMMAND ${LDCONFIG_EXECUTABLE} RESULT_VARIABLE ldconfig_result) | ||
|
||
if (NOT ldconfig_result EQUAL 0) | ||
message(WARNING "ldconfig failed") | ||
endif() | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
message("-- Building for windows (x86) with precompiled packaged dependencies") | ||
|
||
ADD_DEFINITIONS(/bigobj) | ||
|
||
SET(WINDOWS_32_BIT 1) | ||
|
||
# BIG FAT STINKY KLUDGE | ||
SET(CMAKE_CXX_COMPILER_WORKS 1) |
Oops, something went wrong.