athena/CMakeLists.txt

269 lines
8.6 KiB
CMake
Raw Normal View History

if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
2017-11-13 20:50:41 -08:00
cmake_minimum_required(VERSION 3.10 FATAL_ERROR) # because of c++17
2016-03-04 15:00:12 -08:00
project(athena)
2017-11-12 22:12:37 -08:00
set(CMAKE_CXX_STANDARD 17)
2017-06-17 19:50:29 -07:00
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endif()
2015-07-06 20:23:37 -07:00
2015-07-08 16:53:40 -07:00
##################
# Athena Version #
##################
set(ATHENA_MAJOR_VERSION 2)
2015-08-02 18:21:19 -07:00
set(ATHENA_MINOR_VERSION 3)
2015-07-08 16:53:40 -07:00
set(ATHENA_PATCH_VERSION 0)
set(ATHENA_VERSION
${ATHENA_MAJOR_VERSION}.${ATHENA_MINOR_VERSION}.${ATHENA_PATCH_VERSION})
################
# Athena Build #
################
2015-07-06 20:23:37 -07:00
add_subdirectory(extern)
include_directories(include ${LZO_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR})
2015-07-06 20:23:37 -07:00
if(WIN32)
list(APPEND CORE_EXTRA src/win32_largefilewrapper.c include/win32_largefilewrapper.h
src/athena/FileWriterWin32.cpp src/athena/FileReaderWin32.cpp)
else()
2017-01-26 19:25:48 -08:00
list(APPEND CORE_EXTRA src/athena/FileWriterNix.cpp src/athena/FileReader.cpp)
2016-10-27 16:44:50 -07:00
if(APPLE OR GEKKO OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
2015-10-16 01:07:54 -07:00
list(APPEND CORE_EXTRA src/osx_largefilewrapper.c include/osx_largefilewrapper.h)
if(GEKKO)
list(APPEND CORE_EXTRA src/gekko_support.c include/gekko_support.h)
endif()
2015-07-06 20:23:37 -07:00
endif()
endif()
2015-07-06 20:23:37 -07:00
2016-03-04 15:00:12 -08:00
add_library(athena-core
src/athena/Utility.cpp
src/athena/MemoryReader.cpp
src/athena/MemoryWriter.cpp
2017-01-26 19:25:48 -08:00
src/athena/FileWriterGeneric.cpp
2016-03-04 15:00:12 -08:00
src/athena/Global.cpp
src/athena/Checksums.cpp
src/athena/Compression.cpp
2015-07-06 20:23:37 -07:00
src/LZ77/LZLookupTable.cpp
src/LZ77/LZType10.cpp
src/LZ77/LZType11.cpp
src/LZ77/LZBase.cpp
2016-03-04 15:00:12 -08:00
src/athena/FileInfo.cpp
src/athena/Dir.cpp
src/athena/DNAYaml.cpp
2015-07-06 20:23:37 -07:00
${CORE_EXTRA}
2016-03-04 15:00:12 -08:00
include/athena/IStream.hpp
include/athena/IStreamReader.hpp
include/athena/IStreamWriter.hpp
include/athena/Types.hpp
include/athena/Utility.hpp
include/athena/Global.hpp
include/athena/FileReader.hpp
include/athena/FileWriter.hpp
include/athena/MemoryReader.hpp
include/athena/MemoryWriter.hpp
include/athena/Checksums.hpp
include/athena/Compression.hpp
2017-01-06 21:03:13 -08:00
include/athena/Socket.hpp
2015-07-06 20:23:37 -07:00
include/LZ77/LZBase.hpp
include/LZ77/LZLookupTable.hpp
include/LZ77/LZType10.hpp
include/LZ77/LZType11.hpp
2016-03-04 15:00:12 -08:00
include/athena/FileInfo.hpp
include/athena/Dir.hpp
include/athena/DNA.hpp
include/athena/DNAYaml.hpp
2015-08-31 14:11:42 -07:00
include/yaml.h
include/utf8proc.h
2016-03-25 19:22:04 -07:00
include/optional.hpp
2015-07-06 20:23:37 -07:00
)
2016-03-04 15:00:12 -08:00
add_library(athena-sakura EXCLUDE_FROM_ALL
src/athena/Sprite.cpp
src/athena/SpriteFile.cpp
src/athena/SpriteFileReader.cpp
src/athena/SpriteFileWriter.cpp
src/athena/SpriteFrame.cpp
src/athena/SpritePart.cpp
2015-07-06 20:23:37 -07:00
2016-03-04 15:00:12 -08:00
include/athena/SakuraGlobal.hpp
include/athena/Sprite.hpp
include/athena/SpriteFile.hpp
include/athena/SpriteFileReader.hpp
include/athena/SpriteFileWriter.hpp
include/athena/SpriteFrame.hpp
include/athena/SpritePart.hpp
2015-07-06 20:23:37 -07:00
)
2016-03-04 15:00:12 -08:00
add_library(athena-wiisave EXCLUDE_FROM_ALL
src/athena/WiiBanner.cpp
src/athena/WiiFile.cpp
src/athena/WiiImage.cpp
src/athena/WiiSave.cpp
src/athena/WiiSaveReader.cpp
src/athena/WiiSaveWriter.cpp
src/bn.cpp
src/ec.cpp
2015-07-06 20:23:37 -07:00
src/md5.cpp
src/sha1.cpp
src/aes.cpp
2015-07-06 20:23:37 -07:00
2016-03-04 15:00:12 -08:00
include/athena/WiiBanner.hpp
include/athena/WiiFile.hpp
include/athena/WiiImage.hpp
include/athena/WiiSave.hpp
include/athena/WiiSaveReader.hpp
include/athena/WiiSaveWriter.hpp
include/aes.hpp
include/bn.hpp
include/ec.hpp
2015-07-06 20:23:37 -07:00
include/md5.h
include/sha1.h
)
2015-10-16 01:07:54 -07:00
if(NOT MSVC AND NOT GEKKO)
set_source_files_properties(src/aes.cpp PROPERTIES COMPILE_FLAGS -maes)
endif()
2015-07-06 20:23:37 -07:00
2016-03-04 15:00:12 -08:00
add_library(athena-zelda EXCLUDE_FROM_ALL
src/athena/ALTTPFile.cpp
src/athena/ALTTPFileReader.cpp
src/athena/ALTTPFileWriter.cpp
src/athena/ALTTPQuest.cpp
src/athena/MCFile.cpp
src/athena/MCFileReader.cpp
src/athena/MCFileWriter.cpp
src/athena/MCSlot.cpp
src/athena/SkywardSwordFile.cpp
src/athena/SkywardSwordFileReader.cpp
src/athena/SkywardSwordFileWriter.cpp
src/athena/SkywardSwordQuest.cpp
src/athena/ZQuestFile.cpp
src/athena/ZQuestFileReader.cpp
src/athena/ZQuestFileWriter.cpp
2015-07-06 20:23:37 -07:00
2016-03-04 15:00:12 -08:00
include/athena/ALTTPEnums.hpp
include/athena/ALTTPFile.hpp
include/athena/ALTTPFileReader.hpp
include/athena/ALTTPFileWriter.hpp
include/athena/ALTTPQuest.hpp
include/athena/ALTTPStructs.hpp
include/athena/MCFile.hpp
include/athena/MCFileReader.hpp
include/athena/MCFileWriter.hpp
include/athena/SkywardSwordFile.hpp
include/athena/SkywardSwordFileReader.hpp
include/athena/SkywardSwordFileWriter.hpp
include/athena/SkywardSwordQuest.hpp
include/athena/ZQuestFile.hpp
include/athena/ZQuestFileReader.hpp
include/athena/ZQuestFileWriter.hpp
2015-07-06 20:23:37 -07:00
)
2015-08-03 20:42:44 -07:00
# Icon
set(ATHENA_ICO ${CMAKE_CURRENT_SOURCE_DIR}/Athena.ico)
2015-07-08 16:53:40 -07:00
# Offer the user the choice of overriding the installation directories
set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries")
set(INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files")
if(WIN32 AND NOT CYGWIN)
set(INSTALL_CMAKE_DIR cmake)
2015-07-08 16:53:40 -07:00
else()
2016-03-04 15:00:12 -08:00
set(INSTALL_CMAKE_DIR lib/cmake/athena)
2015-07-08 16:53:40 -07:00
endif()
2015-07-06 20:23:37 -07:00
2015-07-08 16:53:40 -07:00
# Make relative paths absolute (needed later on)
foreach(p LIB INCLUDE CMAKE)
set(var INSTALL_${p}_DIR)
if(NOT IS_ABSOLUTE "${${var}}")
2015-07-08 17:57:51 -07:00
set(ABS_${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
else()
set(ABS_${var} "${${var}}")
2015-07-08 16:53:40 -07:00
endif()
endforeach()
# Define installs
2016-03-04 15:00:12 -08:00
install(DIRECTORY include/ DESTINATION ${INSTALL_INCLUDE_DIR}/athena COMPONENT athena)
install(TARGETS athena-core
DESTINATION ${INSTALL_LIB_DIR} EXPORT AthenaTargets COMPONENT athena)
2015-07-08 16:53:40 -07:00
if(WIN32 AND NOT CYGWIN)
2016-03-04 15:00:12 -08:00
install(FILES Athena.ico DESTINATION ${INSTALL_LIB_DIR} COMPONENT athena)
2015-07-08 17:01:05 -07:00
elseif(UNIX)
configure_file(libAthena.pc.in libAthena.pc @ONLY)
configure_file(PKGBUILD.in ${CMAKE_CURRENT_SOURCE_DIR}/PKGBUILD @ONLY)
2017-12-06 20:07:33 -08:00
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libAthena.pc
2016-03-04 15:00:12 -08:00
DESTINATION ${INSTALL_LIB_DIR}/pkgconfig COMPONENT athena)
endif()
2015-07-08 16:53:40 -07:00
##################
# Package Export #
##################
# Add all targets to the build-tree export set
2017-12-06 20:07:33 -08:00
export(TARGETS athena-core FILE "${CMAKE_CURRENT_BINARY_DIR}/AthenaTargets.cmake")
2015-07-08 16:53:40 -07:00
# Export the package for use from the build-tree
# (this registers the build-tree with a global CMake-registry)
2016-03-04 15:00:12 -08:00
export(PACKAGE athena)
2015-07-08 16:53:40 -07:00
# Create the AthenaConfig.cmake
# ... for the build tree
2016-03-04 15:00:12 -08:00
set(CONF_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/include/athena")
2015-07-08 16:53:40 -07:00
set(CONF_ICON_DIR "${PROJECT_SOURCE_DIR}/Athena.ico")
2017-12-06 20:07:33 -08:00
configure_file(AthenaConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/AthenaConfig.cmake" @ONLY)
2015-07-08 16:53:40 -07:00
# ... for the install tree
2015-07-08 17:57:51 -07:00
file(RELATIVE_PATH REL_INCLUDE_DIR "${ABS_INSTALL_CMAKE_DIR}" "${ABS_INSTALL_INCLUDE_DIR}")
file(RELATIVE_PATH REL_ICON_DIR "${ABS_INSTALL_CMAKE_DIR}" "${ABS_INSTALL_LIB_DIR}/Athena.ico")
2016-03-04 15:00:12 -08:00
set(CONF_INCLUDE_DIR "\${ATHENA_CMAKE_DIR}/${REL_INCLUDE_DIR}/athena")
2015-07-08 16:53:40 -07:00
set(CONF_ICON_DIR "\${ATHENA_CMAKE_DIR}/${REL_ICON_DIR}")
2017-12-06 20:07:33 -08:00
configure_file(AthenaConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/AthenaConfig.cmake" @ONLY)
2015-07-08 16:53:40 -07:00
# ... for both
2017-12-06 20:07:33 -08:00
configure_file(AthenaConfigVersion.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/AthenaConfigVersion.cmake" @ONLY)
2015-07-08 16:53:40 -07:00
# Install AthenaConfig.cmake
install(FILES
2017-12-06 20:07:33 -08:00
"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/AthenaConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/AthenaConfigVersion.cmake"
2016-03-04 15:00:12 -08:00
DESTINATION ${INSTALL_CMAKE_DIR} COMPONENT athena)
2015-07-08 16:53:40 -07:00
# Install the export set for use with the install-tree
2016-03-04 15:00:12 -08:00
install(EXPORT AthenaTargets DESTINATION ${INSTALL_CMAKE_DIR} COMPONENT athena)
################
# atdna import #
################
2015-10-16 01:07:54 -07:00
if(NOT GEKKO)
2015-08-02 18:42:47 -07:00
add_subdirectory(atdna)
2015-10-16 01:07:54 -07:00
endif()
2015-07-08 16:53:40 -07:00
#########
# CPack #
#########
include(InstallRequiredSystemLibraries)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Athena")
set(CPACK_PACKAGE_VENDOR "Antidote / Jackoalan")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
2015-07-08 16:53:40 -07:00
set(CPACK_PACKAGE_VERSION_MAJOR ${ATHENA_MAJOR_VERSION})
set(CPACK_PACKAGE_VERSION_MINOR ${ATHENA_MINOR_VERSION})
set(CPACK_PACKAGE_VERSION_PATCH ${ATHENA_PATCH_VERSION})
2016-03-04 15:00:12 -08:00
set(CPACK_PACKAGE_INSTALL_DIRECTORY "athena")
if(WIN32 AND NOT UNIX)
# There is a bug in NSI that does not handle full unix paths properly. Make
# sure there is at least one set of four (4) backlasshes.
2016-03-04 15:00:12 -08:00
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "athena")
set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\AthenaNSIS.bmp")
set(CPACK_NSIS_MODIFY_PATH ON)
set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\Athena.ico")
set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}\\\\Athena.ico")
set(CPACK_NSIS_INSTALLED_ICON_NAME "Uninstall.exe")
set(CPACK_NSIS_DISPLAY_NAME "Athena")
set(CPACK_NSIS_URL_INFO_ABOUT "http://libathena.github.io")
set(CPACK_NSIS_CONTACT "antidote.crk@gmail.com")
endif()
include(CPack)
2015-07-06 20:23:37 -07:00