-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
127 additions
and
226 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,24 @@ | ||
project(StormLib) | ||
cmake_minimum_required(VERSION 2.8.12) | ||
# | ||
# This code is part of MaNGOS. Contributor & Copyright details are in AUTHORS/THANKS. | ||
# | ||
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
# | ||
|
||
set(LIBRARY_NAME stormlib) | ||
|
||
include(CMakeDependentOption) | ||
project(StormLib VERSION 9.22) | ||
|
||
option(BUILD_SHARED_LIBS "Compile shared libraries" OFF) | ||
option(STORM_SKIP_INSTALL "Skip installing files" OFF) | ||
option(STORM_BUILD_TESTS | ||
"Compile StormLib test application" OFF | ||
# "BUILD_TESTING" OFF # Stay coherent with CTest variables | ||
) | ||
set(LIBRARY_NAME stormlib) | ||
|
||
set(SRC_FILES | ||
src/adpcm/adpcm.cpp | ||
|
@@ -45,14 +53,6 @@ set(SRC_FILES | |
src/libtomcrypt/src/misc/crypt_libc.c | ||
) | ||
|
||
if(MSVC) | ||
# This file is used to create a DLL on windows | ||
# Use BUILD_SHARED_LIBS to create StormLib.dll | ||
set(STORM_DEF_FILES | ||
src/DllMain.def | ||
) | ||
endif() | ||
|
||
set(TOMCRYPT_FILES | ||
src/libtomcrypt/src/hashes/hash_memory.c | ||
src/libtomcrypt/src/hashes/md5.c | ||
|
@@ -253,122 +253,26 @@ set(TOMMATH_FILES | |
src/libtommath/bn_s_mp_sub.c | ||
) | ||
|
||
# Needed for Windows | ||
set(ZLIB_BZIP2_FILES | ||
src/bzip2/blocksort.c | ||
src/bzip2/bzlib.c | ||
src/bzip2/compress.c | ||
src/bzip2/crctable.c | ||
src/bzip2/decompress.c | ||
src/bzip2/huffman.c | ||
src/bzip2/randtable.c | ||
src/zlib/adler32.c | ||
src/zlib/compress.c | ||
src/zlib/crc32.c | ||
src/zlib/deflate.c | ||
src/zlib/inffast.c | ||
src/zlib/inflate.c | ||
src/zlib/inftrees.c | ||
src/zlib/trees.c | ||
src/zlib/zutil.c | ||
) | ||
|
||
set(TEST_SRC_FILES | ||
test/StormTest.cpp | ||
) | ||
|
||
add_definitions(-D_7ZIP_ST -DBZ_STRICT_ANSI) | ||
|
||
if(WIN32) | ||
set(SRC_ADDITIONAL_FILES ${ZLIB_BZIP2_FILES} ${TOMCRYPT_FILES} ${TOMMATH_FILES}) | ||
set(LINK_LIBS wininet) | ||
else() | ||
find_package(ZLIB REQUIRED) | ||
find_package(BZip2 REQUIRED) | ||
|
||
include_directories(${ZLIB_INCLUDE_DIR} ${BZIP2_INCLUDE_DIR}) | ||
set(LINK_LIBS ${ZLIB_LIBRARY} ${BZIP2_LIBRARIES}) | ||
|
||
add_definitions(-D__SYS_ZLIB -D__SYS_BZLIB) | ||
|
||
option(WITH_LIBTOMCRYPT "Use system LibTomCrypt library" OFF) | ||
if(WITH_LIBTOMCRYPT) | ||
set(LINK_LIBS ${LINK_LIBS} tomcrypt) | ||
else() | ||
set(SRC_ADDITIONAL_FILES ${TOMCRYPT_FILES} ${TOMMATH_FILES}) | ||
endif() | ||
endif() | ||
set(SRC_ADDITIONAL_FILES ${TOMCRYPT_FILES} ${TOMMATH_FILES}) | ||
add_definitions(-D_7ZIP_ST -DBZ_STRICT_ANSI -D__SYS_ZLIB -D__SYS_BZLIB) | ||
|
||
if(${CMAKE_SYSTEM_NAME} STREQUAL FreeBSD) | ||
message(STATUS "Using FreeBSD port") | ||
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_link_libraries(${LIBRARY_NAME} ${LINK_LIBS}) | ||
target_compile_definitions(${LIBRARY_NAME} INTERFACE STORMLIB_NO_AUTO_LINK) #CMake will take care of the linking | ||
target_include_directories(${LIBRARY_NAME} PUBLIC src/) | ||
set_target_properties(${LIBRARY_NAME} PROPERTIES PUBLIC_HEADER "src/StormLib.h;src/StormPort.h") | ||
if(BUILD_SHARED_LIBS) | ||
message(STATUS "Linking against dependent libraries dynamically") | ||
|
||
if(APPLE) | ||
set_target_properties(${LIBRARY_NAME} PROPERTIES FRAMEWORK true) | ||
set_target_properties(${LIBRARY_NAME} PROPERTIES LINK_FLAGS "-framework Carbon") | ||
endif() | ||
if(UNIX) | ||
SET(VERSION_MAJOR "9") | ||
SET(VERSION_MINOR "22") | ||
SET(VERSION_PATCH "0") | ||
SET(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") | ||
set_target_properties(${LIBRARY_NAME} PROPERTIES VERSION "${VERSION_STRING}") | ||
set_target_properties(${LIBRARY_NAME} PROPERTIES SOVERSION "${VERSION_MAJOR}") | ||
endif() | ||
else() | ||
message(STATUS "Linking against dependent libraries statically") | ||
endif() | ||
|
||
if (NOT STORM_SKIP_INSTALL) | ||
install(TARGETS ${LIBRARY_NAME} | ||
RUNTIME DESTINATION bin | ||
LIBRARY DESTINATION lib | ||
ARCHIVE DESTINATION lib | ||
FRAMEWORK DESTINATION /Library/Frameworks | ||
PUBLIC_HEADER DESTINATION include | ||
INCLUDES DESTINATION include) | ||
|
||
#CPack configurtion | ||
SET(CPACK_GENERATOR "DEB" "RPM") | ||
SET(CPACK_PACKAGE_NAME ${PROJECT_NAME}) | ||
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MPQ manipulation library") | ||
SET(CPACK_PACKAGE_VENDOR "Ladislav Zezula") | ||
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md") | ||
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") | ||
SET(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}") | ||
SET(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}") | ||
SET(CPACK_PACKAGE_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}") | ||
add_library( | ||
${LIBRARY_NAME} | ||
STATIC | ||
${SRC_FILES} | ||
${SRC_ADDITIONAL_FILES} | ||
) | ||
|
||
#DEB configuration | ||
SET(CPACK_DEBIAN_PACKAGE_SECTION "libs") | ||
SET(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://www.zezula.net/en/mpq/stormlib.html") | ||
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "[email protected]") | ||
SET(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64") | ||
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "zlib1g,bzip2") | ||
|
||
#RPM configuration | ||
SET(CPACK_RPM_PACKAGE_RELEASE 1) | ||
SET(CPACK_RPM_PACKAGE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") | ||
SET(CPACK_RPM_PACKAGE_GROUP "${PROJECT_NAME}") | ||
SET(CPACK_RPM_PACKAGE_URL "http://www.zezula.net/en/mpq/stormlib.html") | ||
SET(CPACK_RPM_PACKAGE_REQUIRES "zlib,bzip2") | ||
|
||
INCLUDE(CPack) | ||
endif() | ||
|
||
if(STORM_BUILD_TESTS) | ||
add_executable(StormLib_test ${TEST_SRC_FILES}) | ||
target_link_libraries(StormLib_test ${LIBRARY_NAME}) | ||
install(TARGETS StormLib_test RUNTIME DESTINATION bin) | ||
set(LINK_LIBS ${LINK_LIBS} ZLIB::ZLIB BZip2::BZip2) | ||
if(WIN32) | ||
set(LINK_LIBS ${LINK_LIBS} wininet) | ||
endif() | ||
|
||
target_link_libraries(${LIBRARY_NAME} PRIVATE ${LINK_LIBS}) | ||
target_compile_definitions(${LIBRARY_NAME} INTERFACE STORMLIB_NO_AUTO_LINK) | ||
target_include_directories(${LIBRARY_NAME} PUBLIC src/) | ||
set_target_properties(${LIBRARY_NAME} PROPERTIES PUBLIC_HEADER "src/StormLib.h;src/StormPort.h") |
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
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
Oops, something went wrong.