diff options
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d17ebe..c78e88a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -project(StormLib) cmake_minimum_required(VERSION 3.10) +project(StormLib) set(LIBRARY_NAME storm) set(CMAKE_CXX_STANDARD 11) @@ -9,17 +9,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) include(CMakeDependentOption) include(GNUInstallDirs) -option(STORM_UNICODE "Compile UNICODE version instead of ANSI one (Visual Studio only)" OFF) - -if(WIN32) - if(STORM_UNICODE) - message(STATUS "Build UNICODE version") - add_definitions(-DUNICODE -D_UNICODE) - else() - message(STATUS "Build ANSI version") - endif() -endif() - option(BUILD_SHARED_LIBS "Compile shared libraries" OFF) option(STORM_SKIP_INSTALL "Skip installing files" OFF) option(STORM_USE_BUNDLED_LIBRARIES @@ -296,17 +285,15 @@ set(ZLIB_FILES src/zlib/zutil.c ) -set(TEST_SRC_FILES - test/StormTest.cpp -) +add_library(${LIBRARY_NAME} ${LIB_TYPE}) -add_definitions(-D_7ZIP_ST -DBZ_STRICT_ANSI) +target_compile_definitions(${LIBRARY_NAME} PRIVATE -D_7ZIP_ST -DBZ_STRICT_ANSI) set(LINK_LIBS) find_package(ZLIB) if (ZLIB_FOUND AND NOT STORM_USE_BUNDLED_LIBRARIES) set(LINK_LIBS ${LINK_LIBS} ZLIB::ZLIB) - add_definitions(-D__SYS_ZLIB) + target_compile_definitions(${LIBRARY_NAME} PRIVATE -D__SYS_ZLIB) else() set(SRC_FILES ${SRC_FILES} ${ZLIB_FILES}) endif() @@ -314,7 +301,7 @@ endif() find_package(BZip2) if (BZIP2_FOUND AND NOT STORM_USE_BUNDLED_LIBRARIES) set(LINK_LIBS ${LINK_LIBS} BZip2::BZip2) - add_definitions(-D__SYS_BZLIB) + target_compile_definitions(${LIBRARY_NAME} PRIVATE -D__SYS_BZLIB) else() set(SRC_FILES ${SRC_FILES} ${BZIP2_FILES}) endif() @@ -330,7 +317,7 @@ else() find_path(LIBTOMCRYPT_INCLUDE_DIR NAMES tomcrypt.h HINTS ${PC_LIBTOMCRYPT_INCLUDE_DIRS} REQUIRED) find_library(LIBTOMCRYPT_LIBRARY NAMES tomcrypt HINTS ${PC_LIBTOMCRYPT_LIBRARY_DIRS} REQUIRED) set(LINK_LIBS ${LINK_LIBS} ${LIBTOMCRYPT_LIBRARY}) - include_directories(${LIBTOMCRYPT_INCLUDE_DIR}) + target_include_directories(${LIBRARY_NAME} PRIVATE ${LIBTOMCRYPT_INCLUDE_DIR}) else() set(SRC_ADDITIONAL_FILES ${TOMCRYPT_FILES} ${TOMMATH_FILES}) endif() @@ -341,11 +328,22 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "(Free|Net|Open)BSD") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DO_LARGEFILE=0 -Dstat64=stat -Dlstat64=lstat -Dlseek64=lseek -Doff64_t=off_t -Dfstat64=fstat -Dftruncate64=ftruncate") endif() -add_library(${LIBRARY_NAME} ${LIB_TYPE} ${SRC_FILES} ${SRC_ADDITIONAL_FILES} ${STORM_DEF_FILES}) +target_sources(${LIBRARY_NAME} PRIVATE ${SRC_FILES} ${SRC_ADDITIONAL_FILES} ${STORM_DEF_FILES}) if(WIN32) set_target_properties(${LIBRARY_NAME} PROPERTIES OUTPUT_NAME "StormLib") endif() +option(STORM_UNICODE "Compile UNICODE version instead of ANSI one (Visual Studio only)" OFF) + +if(WIN32) + if(STORM_UNICODE) + message(STATUS "Build UNICODE version") + target_compile_definitions(${LIBRARY_NAME} PRIVATE UNICODE _UNICODE) + else() + message(STATUS "Build ANSI version") + endif() +endif() + target_link_libraries(${LIBRARY_NAME} ${LINK_LIBS}) add_library(${PROJECT_NAME}::${LIBRARY_NAME} ALIAS ${LIBRARY_NAME}) # Allow users to link StormLib::storm when using add_subdirectory target_compile_definitions(${LIBRARY_NAME} INTERFACE STORMLIB_NO_AUTO_LINK) #CMake will take care of the linking @@ -360,7 +358,7 @@ if(BUILD_SHARED_LIBS) endif() if(UNIX) SET(VERSION_MAJOR "9") - SET(VERSION_MINOR "22") + SET(VERSION_MINOR "30") SET(VERSION_PATCH "0") SET(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") set_target_properties(${LIBRARY_NAME} PROPERTIES VERSION "${VERSION_STRING}") @@ -392,8 +390,10 @@ if (NOT STORM_SKIP_INSTALL) SET(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}") SET(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}") SET(CPACK_PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}") + SET(CPACK_PACKAGING_INSTALL_PREFIX "/usr/local") #DEB configuration + set(CPACK_DEBIAN_PACKAGE_EPOCH 1) SET(CPACK_DEBIAN_PACKAGE_SECTION "libs") SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://www.zezula.net/en/mpq/stormlib.html") SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "imbacen@gmail.com") @@ -401,6 +401,7 @@ if (NOT STORM_SKIP_INSTALL) SET(CPACK_DEBIAN_PACKAGE_DEPENDS "zlib1g,bzip2") #RPM configuration + set(CPACK_RPM_PACKAGE_EPOCH 1) SET(CPACK_RPM_PACKAGE_RELEASE 1) SET(CPACK_RPM_PACKAGE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") SET(CPACK_RPM_PACKAGE_GROUP "${PROJECT_NAME}") @@ -411,9 +412,7 @@ if (NOT STORM_SKIP_INSTALL) endif() if(STORM_BUILD_TESTS) - find_package(ALSA REQUIRED) - add_executable(StormLib_test ${TEST_SRC_FILES}) - target_link_libraries(StormLib_test ${LIBRARY_NAME} ${ALSA_LIBRARIES}) - install(TARGETS StormLib_test RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) + enable_testing() + add_subdirectory(test) endif() |