Improve CMake files
This commit is contained in:
parent
1226f0f21c
commit
ae25d2d731
17 changed files with 73 additions and 211 deletions
|
@ -25,6 +25,8 @@ option(WITH_MYSQL "include MySQL user accounts support" OFF)
|
||||||
option(WITH_SQLITE3 "include SQLite3 user accounts support" OFF)
|
option(WITH_SQLITE3 "include SQLite3 user accounts support" OFF)
|
||||||
option(WITH_PGSQL "include PostgreSQL user accounts support" OFF)
|
option(WITH_PGSQL "include PostgreSQL user accounts support" OFF)
|
||||||
option(WITH_ODBC "include ODBC user accounts support" OFF)
|
option(WITH_ODBC "include ODBC user accounts support" OFF)
|
||||||
|
|
||||||
|
|
||||||
include(ConfigureChecks.cmake)
|
include(ConfigureChecks.cmake)
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,6 +51,12 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||||
message(FATAL_ERROR "Visual Studio 2015 or higher required")
|
message(FATAL_ERROR "Visual Studio 2015 or higher required")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
add_definitions(
|
||||||
|
-D_CRT_SECURE_NO_DEPRECATE
|
||||||
|
-D_CRT_NONSTDC_NO_DEPRECATE
|
||||||
|
-DUNICODE
|
||||||
|
-D_UNICODE
|
||||||
|
)
|
||||||
|
|
||||||
# DEBUG compiler flags:
|
# DEBUG compiler flags:
|
||||||
# /Zi create debugging information PDB file
|
# /Zi create debugging information PDB file
|
||||||
|
@ -77,7 +85,7 @@ if(WITH_LUA)
|
||||||
add_subdirectory(lua)
|
add_subdirectory(lua)
|
||||||
endif(WITH_LUA)
|
endif(WITH_LUA)
|
||||||
|
|
||||||
ENABLE_TESTING()
|
enable_testing()
|
||||||
|
|
||||||
# uninstall target
|
# uninstall target
|
||||||
configure_file(
|
configure_file(
|
||||||
|
|
|
@ -1,10 +1,4 @@
|
||||||
# put in this file everything that needs to be setup depending
|
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
|
||||||
# on the target architecture
|
|
||||||
|
|
||||||
# our own modules
|
|
||||||
set(CMAKE_MODULE_PATH
|
|
||||||
${CMAKE_SOURCE_DIR}/cmake/Modules
|
|
||||||
)
|
|
||||||
|
|
||||||
# include used modules
|
# include used modules
|
||||||
include(DefineInstallationPaths)
|
include(DefineInstallationPaths)
|
||||||
|
@ -13,7 +7,6 @@ include(CheckFunctionExists)
|
||||||
include(CheckSymbolExists)
|
include(CheckSymbolExists)
|
||||||
include(CheckLibraryExists)
|
include(CheckLibraryExists)
|
||||||
include(CheckCXXCompilerFlag)
|
include(CheckCXXCompilerFlag)
|
||||||
include(CheckCXXSourceCompiles)
|
|
||||||
include(CheckMkdirArgs)
|
include(CheckMkdirArgs)
|
||||||
include(CheckIncludeFiles)
|
include(CheckIncludeFiles)
|
||||||
|
|
||||||
|
@ -35,13 +28,10 @@ else(WIN32)
|
||||||
set(D2DBS_DEFAULT_CONF_FILE "${SYSCONFDIR}/d2dbs.conf")
|
set(D2DBS_DEFAULT_CONF_FILE "${SYSCONFDIR}/d2dbs.conf")
|
||||||
endif(WIN32)
|
endif(WIN32)
|
||||||
|
|
||||||
enable_language(C)
|
|
||||||
# library checks
|
# library checks
|
||||||
|
if(WITH_BNETD)
|
||||||
find_package(ZLIB REQUIRED)
|
find_package(ZLIB REQUIRED)
|
||||||
check_library_exists(nsl gethostbyname "" HAVE_LIBNSL)
|
endif(WITH_BNETD)
|
||||||
check_library_exists(socket socket "" HAVE_LIBSOCKET)
|
|
||||||
check_library_exists(resolv inet_aton "" HAVE_LIBRESOLV)
|
|
||||||
check_library_exists(bind __inet_aton "" HAVE_LIBBIND)
|
|
||||||
|
|
||||||
if(WITH_LUA)
|
if(WITH_LUA)
|
||||||
find_package(Lua REQUIRED)
|
find_package(Lua REQUIRED)
|
||||||
|
@ -61,8 +51,12 @@ if(WITH_PGSQL)
|
||||||
find_package(PostgreSQL REQUIRED)
|
find_package(PostgreSQL REQUIRED)
|
||||||
endif(WITH_PGSQL)
|
endif(WITH_PGSQL)
|
||||||
|
|
||||||
# if any of nsl or socket exists we need to make sure the following tests
|
|
||||||
# use them otherwise some functions may not be found
|
check_library_exists(nsl gethostbyname "" HAVE_LIBNSL)
|
||||||
|
check_library_exists(socket socket "" HAVE_LIBSOCKET)
|
||||||
|
check_library_exists(resolv inet_aton "" HAVE_LIBRESOLV)
|
||||||
|
check_library_exists(bind __inet_aton "" HAVE_LIBBIND)
|
||||||
|
|
||||||
if(HAVE_LIBNSL)
|
if(HAVE_LIBNSL)
|
||||||
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} nsl)
|
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} nsl)
|
||||||
SET(NETWORK_LIBRARIES ${NETWORK_LIBRARIES} nsl)
|
SET(NETWORK_LIBRARIES ${NETWORK_LIBRARIES} nsl)
|
||||||
|
@ -81,7 +75,6 @@ if(HAVE_LIBBIND)
|
||||||
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} bind)
|
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} bind)
|
||||||
SET(NETWORK_LIBRARIES ${NETWORK_LIBRARIES} bind)
|
SET(NETWORK_LIBRARIES ${NETWORK_LIBRARIES} bind)
|
||||||
endif(HAVE_LIBBIND)
|
endif(HAVE_LIBBIND)
|
||||||
|
|
||||||
# for win32 unconditionally add network library linking to "ws2_32"
|
# for win32 unconditionally add network library linking to "ws2_32"
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
SET(NETWORK_LIBRARIES ${NETWORK_LIBRARIES} ws2_32)
|
SET(NETWORK_LIBRARIES ${NETWORK_LIBRARIES} ws2_32)
|
||||||
|
@ -174,17 +167,7 @@ check_function_exists(uname HAVE_UNAME)
|
||||||
check_function_exists(wait HAVE_WAIT)
|
check_function_exists(wait HAVE_WAIT)
|
||||||
check_function_exists(waitpid HAVE_WAITPID)
|
check_function_exists(waitpid HAVE_WAITPID)
|
||||||
|
|
||||||
CHECK_CXX_SOURCE_COMPILES(
|
|
||||||
"
|
|
||||||
#include <memory>
|
|
||||||
int main() {
|
|
||||||
auto foo = std::make_unique<int>(1);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
" HAVE_MAKE_UNIQUE)
|
|
||||||
|
|
||||||
|
|
||||||
# winsock2.h and ws2_32 should provide these
|
|
||||||
if(HAVE_WINSOCK2_H)
|
if(HAVE_WINSOCK2_H)
|
||||||
set(HAVE_GETHOSTNAME ON)
|
set(HAVE_GETHOSTNAME ON)
|
||||||
set(HAVE_SELECT ON)
|
set(HAVE_SELECT ON)
|
||||||
|
@ -210,14 +193,3 @@ endif(HAVE_WINSOCK2_H)
|
||||||
check_mkdir_args(MKDIR_TAKES_ONE_ARG)
|
check_mkdir_args(MKDIR_TAKES_ONE_ARG)
|
||||||
|
|
||||||
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||||
|
|
||||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
|
||||||
# using Visual Studio
|
|
||||||
|
|
||||||
add_definitions(
|
|
||||||
-D_CRT_SECURE_NO_DEPRECATE
|
|
||||||
-D_CRT_NONSTDC_NO_DEPRECATE
|
|
||||||
-DUNICODE
|
|
||||||
-D_UNICODE
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
# - Find zlib
|
|
||||||
# Find the native ZLIB includes and library
|
|
||||||
#
|
|
||||||
# ZLIB_INCLUDE_DIR - where to find zlib.h, etc.
|
|
||||||
# ZLIB_LIBRARIES - List of libraries when using zlib.
|
|
||||||
# ZLIB_FOUND - True if zlib found.
|
|
||||||
|
|
||||||
|
|
||||||
IF (ZLIB_INCLUDE_DIR)
|
|
||||||
# Already in cache, be silent
|
|
||||||
SET(ZLIB_FIND_QUIETLY TRUE)
|
|
||||||
ENDIF (ZLIB_INCLUDE_DIR)
|
|
||||||
|
|
||||||
FIND_PATH(ZLIB_INCLUDE_DIR zlib.h
|
|
||||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]/include"
|
|
||||||
/usr/local/include
|
|
||||||
/usr/include
|
|
||||||
${CMAKE_SOURCE_DIR}/zlib
|
|
||||||
)
|
|
||||||
|
|
||||||
SET(ZLIB_NAMES z zlib zdll zlibwapi)
|
|
||||||
FIND_LIBRARY(ZLIB_LIBRARY
|
|
||||||
NAMES ${ZLIB_NAMES}
|
|
||||||
PATHS
|
|
||||||
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]/lib"
|
|
||||||
/usr/lib /usr/local/lib ${CMAKE_SOURCE_DIR}/zlib
|
|
||||||
)
|
|
||||||
|
|
||||||
IF (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY)
|
|
||||||
SET(ZLIB_FOUND TRUE)
|
|
||||||
SET( ZLIB_LIBRARIES ${ZLIB_LIBRARY} )
|
|
||||||
ELSE (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY)
|
|
||||||
SET(ZLIB_FOUND FALSE)
|
|
||||||
SET( ZLIB_LIBRARIES )
|
|
||||||
ENDIF (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY)
|
|
||||||
|
|
||||||
IF (ZLIB_FOUND)
|
|
||||||
IF (NOT ZLIB_FIND_QUIETLY)
|
|
||||||
MESSAGE(STATUS "Found ZLIB: ${ZLIB_LIBRARY}")
|
|
||||||
ENDIF (NOT ZLIB_FIND_QUIETLY)
|
|
||||||
ELSE (ZLIB_FOUND)
|
|
||||||
IF (ZLIB_FIND_REQUIRED)
|
|
||||||
MESSAGE(STATUS "Looked for Z libraries named ${ZLIB_NAMES}.")
|
|
||||||
MESSAGE(FATAL_ERROR "Could NOT find z library")
|
|
||||||
ENDIF (ZLIB_FIND_REQUIRED)
|
|
||||||
ENDIF (ZLIB_FOUND)
|
|
||||||
|
|
||||||
MARK_AS_ADVANCED(
|
|
||||||
ZLIB_LIBRARY
|
|
||||||
ZLIB_INCLUDE_DIR
|
|
||||||
)
|
|
|
@ -54,7 +54,6 @@
|
||||||
#cmakedefine HAVE_GETUID
|
#cmakedefine HAVE_GETUID
|
||||||
#cmakedefine HAVE_IOCTL
|
#cmakedefine HAVE_IOCTL
|
||||||
#cmakedefine HAVE_KQUEUE
|
#cmakedefine HAVE_KQUEUE
|
||||||
#cmakedefine HAVE_MAKE_UNIQUE
|
|
||||||
#cmakedefine HAVE__MKDIR
|
#cmakedefine HAVE__MKDIR
|
||||||
#cmakedefine HAVE_MKDIR
|
#cmakedefine HAVE_MKDIR
|
||||||
#cmakedefine HAVE_MMAP
|
#cmakedefine HAVE_MMAP
|
||||||
|
|
|
@ -1,15 +1,5 @@
|
||||||
#first setup the includes and link paths
|
include_directories(${CMAKE_SOURCE_DIR}/src ${CMAKE_BINARY_DIR})
|
||||||
include_directories(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src)
|
|
||||||
|
|
||||||
# the following line makes sure all targets will lookup local libraries
|
|
||||||
# when referenced by short names
|
|
||||||
link_directories(${CMAKE_BINARY_DIR}/src/common
|
|
||||||
${CMAKE_BINARY_DIR}/src/compat
|
|
||||||
${CMAKE_BINARY_DIR}/src/win32)
|
|
||||||
|
|
||||||
if(LUA_FOUND)
|
|
||||||
add_definitions("-DWITH_LUA")
|
|
||||||
endif(LUA_FOUND)
|
|
||||||
|
|
||||||
if(MYSQL_FOUND)
|
if(MYSQL_FOUND)
|
||||||
add_definitions("-DWITH_SQL_MYSQL")
|
add_definitions("-DWITH_SQL_MYSQL")
|
||||||
|
@ -21,11 +11,26 @@ if(PGSQL_FOUND)
|
||||||
add_definitions("-DWITH_SQL_PGSQL")
|
add_definitions("-DWITH_SQL_PGSQL")
|
||||||
endif(PGSQL_FOUND)
|
endif(PGSQL_FOUND)
|
||||||
|
|
||||||
|
|
||||||
|
if(LUA_FOUND)
|
||||||
|
add_definitions("-DWITH_LUA")
|
||||||
|
endif(LUA_FOUND)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (WITH_WIN32_GUI)
|
if (WITH_WIN32_GUI)
|
||||||
add_definitions("-DWIN32_GUI")
|
add_definitions("-DWIN32_GUI")
|
||||||
endif (WITH_WIN32_GUI)
|
endif (WITH_WIN32_GUI)
|
||||||
|
|
||||||
subdirs(compat common win32 bntrackd client bniutils bnpass)
|
|
||||||
|
add_subdirectory(bniutils)
|
||||||
|
add_subdirectory(bnpass)
|
||||||
|
add_subdirectory(bntrackd)
|
||||||
|
add_subdirectory(client)
|
||||||
|
add_subdirectory(common)
|
||||||
|
add_subdirectory(compat)
|
||||||
|
add_subdirectory(win32)
|
||||||
|
|
||||||
|
|
||||||
if(WITH_BNETD)
|
if(WITH_BNETD)
|
||||||
add_subdirectory(bnetd)
|
add_subdirectory(bnetd)
|
||||||
|
@ -39,6 +44,7 @@ if(WITH_D2DBS)
|
||||||
add_subdirectory(d2dbs)
|
add_subdirectory(d2dbs)
|
||||||
endif(WITH_D2DBS)
|
endif(WITH_D2DBS)
|
||||||
|
|
||||||
|
|
||||||
if(CMAKE_TESTING_ENABLED)
|
if(CMAKE_TESTING_ENABLED)
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
endif(CMAKE_TESTING_ENABLED)
|
endif(CMAKE_TESTING_ENABLED)
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
# add aditional includes corresponding to the additional libraries bellow
|
|
||||||
include_directories(${ZLIB_INCLUDE_DIR} ${MYSQL_INCLUDE_DIR} ${LUA_INCLUDE_DIR}
|
|
||||||
${SQLITE3_INCLUDE_DIR} ${PGSQL_INCLUDE_DIR} ${ODBC_INCLUDE_DIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
set(BNETD_SOURCES
|
set(BNETD_SOURCES
|
||||||
account.cpp account.h account_wrap.cpp account_wrap.h adbanner.cpp
|
account.cpp account.h account_wrap.cpp account_wrap.h adbanner.cpp
|
||||||
adbanner.h alias_command.cpp alias_command.h anongame.cpp
|
adbanner.h alias_command.cpp alias_command.h anongame.cpp
|
||||||
|
@ -54,13 +49,15 @@ else(WITH_WIN32_GUI)
|
||||||
endif(WITH_WIN32_GUI)
|
endif(WITH_WIN32_GUI)
|
||||||
|
|
||||||
target_include_directories(bnetd
|
target_include_directories(bnetd
|
||||||
PUBLIC
|
|
||||||
$<INSTALL_INTERFACE:lib>
|
|
||||||
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/lib>
|
|
||||||
PRIVATE
|
PRIVATE
|
||||||
${CMAKE_SOURCE_DIR}/src
|
${ZLIB_INCLUDE_DIRS}
|
||||||
|
${LUA_INCLUDE_DIR}
|
||||||
|
${MYSQL_INCLUDE_DIR}
|
||||||
|
${SQLITE3_INCLUDE_DIR}
|
||||||
|
${PGSQL_INCLUDE_DIR}
|
||||||
|
${ODBC_INCLUDE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(bnetd common compat fmt win32 ${NETWORK_LIBRARIES} ${ZLIB_LIBRARIES} ${MYSQL_LIBRARIES} ${SQLITE3_LIBRARIES} ${PGSQL_LIBRARIES} ${ODBC_LIBRARIES} ${LUA_LIBRARIES})
|
target_link_libraries(bnetd PRIVATE common compat fmt win32 ${NETWORK_LIBRARIES} ${ZLIB_LIBRARIES} ${MYSQL_LIBRARIES} ${SQLITE3_LIBRARIES} ${PGSQL_LIBRARIES} ${ODBC_LIBRARIES} ${LUA_LIBRARIES})
|
||||||
|
|
||||||
install(TARGETS bnetd DESTINATION ${SBINDIR})
|
install(TARGETS bnetd DESTINATION ${SBINDIR})
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
add_executable(bnilist bnilist.cpp fileio.cpp fileio.h tga.cpp tga.h)
|
add_executable(bnilist bnilist.cpp fileio.cpp fileio.h tga.cpp tga.h)
|
||||||
target_link_libraries(bnilist common compat)
|
target_link_libraries(bnilist PRIVATE common compat)
|
||||||
|
|
||||||
add_executable(bni2tga bni2tga.cpp fileio.cpp fileio.h)
|
add_executable(bni2tga bni2tga.cpp fileio.cpp fileio.h)
|
||||||
target_link_libraries(bni2tga common)
|
target_link_libraries(bni2tga PRIVATE common)
|
||||||
|
|
||||||
add_executable(bniextract bniextract.cpp fileio.cpp fileio.h tga.cpp tga.h bni.cpp bni.h)
|
add_executable(bniextract bniextract.cpp fileio.cpp fileio.h tga.cpp tga.h bni.cpp bni.h)
|
||||||
target_link_libraries(bniextract common compat)
|
target_link_libraries(bniextract PRIVATE common compat)
|
||||||
|
|
||||||
add_executable(bnibuild bnibuild.cpp fileio.cpp fileio.h bni.cpp bni.h tga.cpp tga.h)
|
add_executable(bnibuild bnibuild.cpp fileio.cpp fileio.h bni.cpp bni.h tga.cpp tga.h)
|
||||||
target_link_libraries(bnibuild common compat)
|
target_link_libraries(bnibuild PRIVATE common compat)
|
||||||
|
|
||||||
add_executable(tgainfo tgainfo.cpp fileio.cpp fileio.h tga.cpp tga.h)
|
add_executable(tgainfo tgainfo.cpp fileio.cpp fileio.h tga.cpp tga.h)
|
||||||
target_link_libraries(tgainfo common compat)
|
target_link_libraries(tgainfo PRIVATE common compat)
|
||||||
|
|
||||||
install(TARGETS bnilist bni2tga bniextract bnibuild tgainfo DESTINATION ${BINDIR})
|
install(TARGETS bnilist bni2tga bniextract bnibuild tgainfo DESTINATION ${BINDIR})
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
add_executable(bnpass bnpass.cpp)
|
add_executable(bnpass bnpass.cpp)
|
||||||
target_link_libraries(bnpass common compat)
|
target_link_libraries(bnpass PRIVATE common compat fmt)
|
||||||
|
|
||||||
add_executable(sha1hash sha1hash.cpp)
|
add_executable(sha1hash sha1hash.cpp)
|
||||||
target_link_libraries(sha1hash common compat)
|
target_link_libraries(sha1hash PRIVATE common compat fmt)
|
||||||
|
|
||||||
install(TARGETS bnpass sha1hash DESTINATION ${BINDIR})
|
install(TARGETS bnpass sha1hash DESTINATION ${BINDIR})
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
add_executable(bntrackd bntrackd.cpp)
|
add_executable(bntrackd bntrackd.cpp)
|
||||||
target_link_libraries(bntrackd common compat ${NETWORK_LIBRARIES})
|
target_link_libraries(bntrackd PRIVATE common compat fmt ${NETWORK_LIBRARIES})
|
||||||
install(TARGETS bntrackd DESTINATION ${SBINDIR})
|
install(TARGETS bntrackd DESTINATION ${SBINDIR})
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
add_executable(bnchat bnchat.cpp client.cpp client.h client_connect.cpp
|
add_executable(bnchat bnchat.cpp client.cpp client.h client_connect.cpp
|
||||||
client_connect.h udptest.cpp udptest.h ansi_term.h)
|
client_connect.h udptest.cpp udptest.h ansi_term.h)
|
||||||
target_link_libraries(bnchat common compat ${NETWORK_LIBRARIES})
|
target_link_libraries(bnchat PRIVATE common compat fmt ${NETWORK_LIBRARIES})
|
||||||
|
|
||||||
add_executable(bnftp bnftp.cpp client.cpp client.h)
|
add_executable(bnftp bnftp.cpp client.cpp client.h)
|
||||||
target_link_libraries(bnftp common compat ${NETWORK_LIBRARIES})
|
target_link_libraries(bnftp PRIVATE common compat fmt ${NETWORK_LIBRARIES})
|
||||||
|
|
||||||
add_executable(bnbot bnbot.cpp client.cpp client.h)
|
add_executable(bnbot bnbot.cpp client.cpp client.h)
|
||||||
target_link_libraries(bnbot common compat ${NETWORK_LIBRARIES})
|
target_link_libraries(bnbot PRIVATE common compat fmt ${NETWORK_LIBRARIES})
|
||||||
|
|
||||||
add_executable(bnstat bnstat.cpp client.cpp client.h client_connect.cpp
|
add_executable(bnstat bnstat.cpp client.cpp client.h client_connect.cpp
|
||||||
client_connect.h udptest.cpp udptest.h)
|
client_connect.h udptest.cpp udptest.h)
|
||||||
target_link_libraries(bnstat common compat ${NETWORK_LIBRARIES})
|
target_link_libraries(bnstat PRIVATE common compat fmt ${NETWORK_LIBRARIES})
|
||||||
|
|
||||||
install(TARGETS bnchat bnftp bnbot bnstat DESTINATION ${BINDIR})
|
install(TARGETS bnchat bnftp bnbot bnstat DESTINATION ${BINDIR})
|
||||||
|
|
|
@ -11,7 +11,7 @@ set(COMMON_SOURCES
|
||||||
fdwbackend.h field_sizes.h file_protocol.h flags.h
|
fdwbackend.h field_sizes.h file_protocol.h flags.h
|
||||||
give_up_root_privileges.cpp give_up_root_privileges.h hashtable.cpp
|
give_up_root_privileges.cpp give_up_root_privileges.h hashtable.cpp
|
||||||
hashtable.h hash_tuple.hpp hexdump.cpp hexdump.h init_protocol.h introtate.h
|
hashtable.h hash_tuple.hpp hexdump.cpp hexdump.h init_protocol.h introtate.h
|
||||||
irc_protocol.h list.cpp list.h lstr.h make_unique.hpp network.cpp network.h
|
irc_protocol.h list.cpp list.h lstr.h network.cpp network.h
|
||||||
packet.cpp packet.h proginfo.cpp proginfo.h queue.cpp queue.h rcm.cpp rcm.h
|
packet.cpp packet.h proginfo.cpp proginfo.h queue.cpp queue.h rcm.cpp rcm.h
|
||||||
rlimit.cpp rlimit.h scoped_array.h scoped_ptr.h setup_after.h
|
rlimit.cpp rlimit.h scoped_array.h scoped_ptr.h setup_after.h
|
||||||
setup_before.h systemerror.cpp systemerror.h tag.cpp tag.h token.cpp
|
setup_before.h systemerror.cpp systemerror.h tag.cpp tag.h token.cpp
|
||||||
|
@ -21,14 +21,6 @@ set(COMMON_SOURCES
|
||||||
bigint.cpp bigint.h bnetsrp3.cpp bnetsrp3.h peerchat.cpp peerchat.h
|
bigint.cpp bigint.h bnetsrp3.cpp bnetsrp3.h peerchat.cpp peerchat.h
|
||||||
wol_gameres_protocol.h pugiconfig.h pugixml.cpp pugixml.h)
|
wol_gameres_protocol.h pugiconfig.h pugixml.cpp pugixml.h)
|
||||||
|
|
||||||
add_library(common ${COMMON_SOURCES})
|
add_library(common STATIC ${COMMON_SOURCES})
|
||||||
|
|
||||||
target_include_directories(common
|
target_link_libraries(common PRIVATE fmt)
|
||||||
PUBLIC
|
|
||||||
$<INSTALL_INTERFACE:lib>
|
|
||||||
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/lib>
|
|
||||||
PRIVATE
|
|
||||||
${CMAKE_SOURCE_DIR}/src
|
|
||||||
)
|
|
||||||
|
|
||||||
target_link_libraries(common PUBLIC fmt)
|
|
|
@ -1,64 +0,0 @@
|
||||||
/*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef MAKE_UNIQUE_H
|
|
||||||
#define MAKE_UNIQUE_H
|
|
||||||
|
|
||||||
#include "common/setup_before.h"
|
|
||||||
|
|
||||||
#ifndef HAVE_MAKE_UNIQUE
|
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <type_traits>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
namespace pvpgn
|
|
||||||
{
|
|
||||||
//https://isocpp.org/files/papers/N3656.txt
|
|
||||||
|
|
||||||
template<class T> struct _Unique_if {
|
|
||||||
typedef std::unique_ptr<T> _Single_object;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class T> struct _Unique_if<T[]> {
|
|
||||||
typedef std::unique_ptr<T[]> _Unknown_bound;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class T, size_t N> struct _Unique_if<T[N]> {
|
|
||||||
typedef void _Known_bound;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class T, class... Args>
|
|
||||||
typename _Unique_if<T>::_Single_object
|
|
||||||
make_unique(Args&&... args) {
|
|
||||||
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
typename _Unique_if<T>::_Unknown_bound
|
|
||||||
make_unique(size_t n) {
|
|
||||||
typedef typename remove_extent<T>::type U;
|
|
||||||
return std::unique_ptr<T>(new U[n]());
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class T, class... Args>
|
|
||||||
typename _Unique_if<T>::_Known_bound
|
|
||||||
make_unique(Args&&...) = delete;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
#define make_unique std::make_unique
|
|
||||||
#endif //HAVE_MAKE_UNIQUE
|
|
||||||
#endif //MAKE_UNIQUE_H
|
|
|
@ -1,8 +1,11 @@
|
||||||
add_library(compat
|
set(COMPAT_SOURCES access.h gethostname.h gettimeofday.cpp gettimeofday.h
|
||||||
access.h gethostname.h gettimeofday.cpp gettimeofday.h
|
|
||||||
mkdir.h mmap.cpp mmap.h netinet_in.h pdir.cpp pdir.h
|
mkdir.h mmap.cpp mmap.h netinet_in.h pdir.cpp pdir.h
|
||||||
pgetopt.cpp pgetopt.h pgetpid.h psock.cpp psock.h read.h recv.h
|
pgetopt.cpp pgetopt.h pgetpid.h psock.cpp psock.h read.h recv.h
|
||||||
rename.h send.h socket.h statmacros.h
|
rename.h send.h socket.h statmacros.h
|
||||||
stdfileno.h strcasecmp.cpp strcasecmp.h strdup.cpp strdup.h
|
stdfileno.h strcasecmp.cpp strcasecmp.h strdup.cpp strdup.h
|
||||||
strerror.cpp strerror.h strncasecmp.cpp strncasecmp.h strsep.cpp
|
strerror.cpp strerror.h strncasecmp.cpp strncasecmp.h strsep.cpp
|
||||||
strsep.h termios.h uname.cpp uname.h)
|
strsep.h termios.h uname.cpp uname.h)
|
||||||
|
|
||||||
|
add_library(compat STATIC ${COMPAT_SOURCES})
|
||||||
|
|
||||||
|
target_link_libraries(compat PRIVATE common fmt)
|
|
@ -15,5 +15,5 @@ else(WITH_WIN32_GUI)
|
||||||
add_executable(d2cs ${D2CS_SOURCES})
|
add_executable(d2cs ${D2CS_SOURCES})
|
||||||
endif(WITH_WIN32_GUI)
|
endif(WITH_WIN32_GUI)
|
||||||
|
|
||||||
target_link_libraries(d2cs common compat win32 ${NETWORK_LIBRARIES})
|
target_link_libraries(d2cs PRIVATE common compat fmt win32 ${NETWORK_LIBRARIES})
|
||||||
install(TARGETS d2cs DESTINATION ${SBINDIR})
|
install(TARGETS d2cs DESTINATION ${SBINDIR})
|
||||||
|
|
|
@ -11,5 +11,5 @@ else(WITH_WIN32_GUI)
|
||||||
add_executable(d2dbs ${D2DBS_SOURCES})
|
add_executable(d2dbs ${D2DBS_SOURCES})
|
||||||
endif(WITH_WIN32_GUI)
|
endif(WITH_WIN32_GUI)
|
||||||
|
|
||||||
target_link_libraries(d2dbs common compat win32 ${NETWORK_LIBRARIES})
|
target_link_libraries(d2dbs PRIVATE common compat fmt win32 ${NETWORK_LIBRARIES})
|
||||||
install(TARGETS d2dbs DESTINATION ${SBINDIR})
|
install(TARGETS d2dbs DESTINATION ${SBINDIR})
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
add_executable(bnetsrp3_test bnetsrp3_test.cpp )
|
add_executable(bnetsrp3_test bnetsrp3_test.cpp )
|
||||||
target_link_libraries(bnetsrp3_test common)
|
target_link_libraries(bnetsrp3_test PRIVATE common)
|
||||||
ADD_TEST(bnetsrp3_test bnetsrp3_test)
|
add_test(bnetsrp3_test bnetsrp3_test)
|
||||||
|
|
||||||
add_executable(bigint bigint.cpp )
|
add_executable(bigint bigint.cpp )
|
||||||
target_link_libraries(bigint common)
|
target_link_libraries(bigint PRIVATE common)
|
||||||
ADD_TEST(bigint bigint)
|
add_test(bigint bigint)
|
||||||
|
|
|
@ -2,4 +2,4 @@ set(WIN32_SOURCES
|
||||||
service.cpp service.h console_output.h console_output.cpp dirent.h windump.cpp windump.h
|
service.cpp service.h console_output.h console_output.cpp dirent.h windump.cpp windump.h
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(win32 ${WIN32_SOURCES})
|
add_library(win32 STATIC ${WIN32_SOURCES})
|
||||||
|
|
Loading…
Reference in a new issue