athena/CMakeLists.txt

301 lines
9.5 KiB
CMake
Raw Normal View History

2017-11-14 04:50:41 +00:00
cmake_minimum_required(VERSION 3.10 FATAL_ERROR) # because of c++17
2016-03-04 23:00:12 +00:00
project(athena)
2017-11-13 06:12:37 +00:00
set(CMAKE_CXX_STANDARD 17)
2017-06-18 02:50:29 +00:00
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2015-07-07 03:23:37 +00:00
2015-07-08 23:53:40 +00:00
##################
# Athena Version #
##################
set(ATHENA_MAJOR_VERSION 2)
2015-08-03 01:21:19 +00:00
set(ATHENA_MINOR_VERSION 3)
2015-07-08 23:53:40 +00:00
set(ATHENA_PATCH_VERSION 0)
set(ATHENA_VERSION
${ATHENA_MAJOR_VERSION}.${ATHENA_MINOR_VERSION}.${ATHENA_PATCH_VERSION})
################
# Athena Build #
################
2015-07-07 03:23:37 +00:00
add_subdirectory(extern)
2016-03-04 23:00:12 +00:00
add_library(athena-core
src/athena/Utility.cpp
src/athena/MemoryReader.cpp
src/athena/MemoryWriter.cpp
2018-08-25 08:38:23 +00:00
src/athena/VectorWriter.cpp
2017-01-27 03:25:48 +00:00
src/athena/FileWriterGeneric.cpp
2016-03-04 23:00:12 +00:00
src/athena/Global.cpp
src/athena/Checksums.cpp
src/athena/Compression.cpp
src/athena/Socket.cpp
2015-07-07 03:23:37 +00:00
src/LZ77/LZLookupTable.cpp
src/LZ77/LZType10.cpp
src/LZ77/LZType11.cpp
src/LZ77/LZBase.cpp
2016-03-04 23:00:12 +00:00
src/athena/FileInfo.cpp
src/athena/Dir.cpp
src/athena/DNAYaml.cpp
2015-07-07 03:23:37 +00:00
2016-03-04 23:00:12 +00: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
2018-08-25 08:38:23 +00:00
include/athena/VectorWriter.hpp
2016-03-04 23:00:12 +00:00
include/athena/Checksums.hpp
2018-03-04 04:24:11 +00:00
include/athena/ChecksumsLiterals.hpp
2016-03-04 23:00:12 +00:00
include/athena/Compression.hpp
2017-01-07 05:03:13 +00:00
include/athena/Socket.hpp
2015-07-07 03:23:37 +00:00
include/LZ77/LZBase.hpp
include/LZ77/LZLookupTable.hpp
include/LZ77/LZType10.hpp
include/LZ77/LZType11.hpp
2016-03-04 23:00:12 +00:00
include/athena/FileInfo.hpp
include/athena/Dir.hpp
include/athena/DNA.hpp
include/athena/DNAYaml.hpp
2018-03-04 04:24:11 +00:00
include/athena/DNAOp.hpp
include/athena/YAMLCommon.hpp
include/athena/YAMLDocReader.hpp
include/athena/YAMLDocWriter.hpp
2015-08-31 21:11:42 +00:00
include/yaml.h
include/utf8proc.h
2015-07-07 03:23:37 +00:00
)
if(WIN32)
target_sources(athena-core PRIVATE
src/win32_largefilewrapper.c
include/win32_largefilewrapper.h
src/athena/FileWriterWin32.cpp
src/athena/FileReaderWin32.cpp
)
else()
target_sources(athena-core PRIVATE
src/athena/FileWriterNix.cpp
src/athena/FileReader.cpp
)
if(APPLE OR GEKKO OR NX OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
target_sources(athena-core PRIVATE
src/osx_largefilewrapper.c
include/osx_largefilewrapper.h
)
if(GEKKO OR NX)
target_sources(athena-core PRIVATE
src/gekko_support.c
include/gekko_support.h
)
endif()
endif()
endif()
target_include_directories(athena-core PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${ZLIB_INCLUDE_DIR}>
)
target_link_libraries(athena-core PUBLIC
athena-libyaml
fmt
)
2015-07-07 03:23:37 +00:00
2016-03-04 23:00:12 +00: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-07 03:23:37 +00:00
2016-03-04 23:00:12 +00: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-07 03:23:37 +00:00
)
2016-03-04 23:00:12 +00: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-07 03:23:37 +00:00
src/md5.cpp
src/sha1.cpp
src/aes.cpp
2015-07-07 03:23:37 +00:00
2016-03-04 23:00:12 +00: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-07 03:23:37 +00:00
include/md5.h
include/sha1.h
)
2018-09-20 17:47:48 +00:00
if(NOT MSVC AND NOT GEKKO AND NOT NX)
set_source_files_properties(src/aes.cpp PROPERTIES COMPILE_FLAGS -maes)
endif()
2015-07-07 03:23:37 +00:00
2016-03-04 23:00:12 +00: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-07 03:23:37 +00:00
2016-03-04 23:00:12 +00: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-07 03:23:37 +00:00
)
2015-08-04 03:42:44 +00:00
# Icon
set(ATHENA_ICO ${CMAKE_CURRENT_SOURCE_DIR}/Athena.ico)
2015-07-08 23:53:40 +00: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 23:53:40 +00:00
else()
2016-03-04 23:00:12 +00:00
set(INSTALL_CMAKE_DIR lib/cmake/athena)
2015-07-08 23:53:40 +00:00
endif()
2015-07-07 03:23:37 +00:00
2015-07-08 23:53:40 +00: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-09 00:57:51 +00:00
set(ABS_${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
else()
set(ABS_${var} "${${var}}")
2015-07-08 23:53:40 +00:00
endif()
endforeach()
# Define installs
2019-07-20 04:19:44 +00:00
install(DIRECTORY include DESTINATION ${INSTALL_INCLUDE_DIR}/athena COMPONENT athena)
install(DIRECTORY extern/fmt/include DESTINATION ${INSTALL_INCLUDE_DIR}/fmt COMPONENT athena)
2016-03-04 23:00:12 +00:00
install(TARGETS athena-core
DESTINATION ${INSTALL_LIB_DIR} EXPORT AthenaTargets COMPONENT athena)
2015-07-08 23:53:40 +00:00
if(WIN32 AND NOT CYGWIN)
2016-03-04 23:00:12 +00:00
install(FILES Athena.ico DESTINATION ${INSTALL_LIB_DIR} COMPONENT athena)
2015-07-09 00:01:05 +00:00
elseif(UNIX)
configure_file(libAthena.pc.in libAthena.pc @ONLY)
configure_file(PKGBUILD.in ${CMAKE_CURRENT_SOURCE_DIR}/PKGBUILD @ONLY)
2017-12-07 04:07:33 +00:00
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libAthena.pc
2016-03-04 23:00:12 +00:00
DESTINATION ${INSTALL_LIB_DIR}/pkgconfig COMPONENT athena)
endif()
2015-07-08 23:53:40 +00:00
##################
# Package Export #
##################
# Add all targets to the build-tree export set
2019-07-20 04:19:44 +00:00
export(TARGETS athena-core athena-libyaml fmt FILE "${CMAKE_CURRENT_BINARY_DIR}/AthenaTargets.cmake")
2015-07-08 23:53:40 +00:00
# Export the package for use from the build-tree
# (this registers the build-tree with a global CMake-registry)
2016-03-04 23:00:12 +00:00
export(PACKAGE athena)
2015-07-08 23:53:40 +00:00
# Create the AthenaConfig.cmake
# ... for the build tree
2016-03-04 23:00:12 +00:00
set(CONF_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/include/athena")
2015-07-08 23:53:40 +00:00
set(CONF_ICON_DIR "${PROJECT_SOURCE_DIR}/Athena.ico")
2017-12-07 04:07:33 +00:00
configure_file(AthenaConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/AthenaConfig.cmake" @ONLY)
2015-07-08 23:53:40 +00:00
# ... for the install tree
2015-07-09 00:57:51 +00: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 23:00:12 +00:00
set(CONF_INCLUDE_DIR "\${ATHENA_CMAKE_DIR}/${REL_INCLUDE_DIR}/athena")
2015-07-08 23:53:40 +00:00
set(CONF_ICON_DIR "\${ATHENA_CMAKE_DIR}/${REL_ICON_DIR}")
2017-12-07 04:07:33 +00:00
configure_file(AthenaConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/AthenaConfig.cmake" @ONLY)
2015-07-08 23:53:40 +00:00
# ... for both
2017-12-07 04:07:33 +00:00
configure_file(AthenaConfigVersion.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/AthenaConfigVersion.cmake" @ONLY)
2015-07-08 23:53:40 +00:00
# Install AthenaConfig.cmake
install(FILES
2017-12-07 04:07:33 +00:00
"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/AthenaConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/AthenaConfigVersion.cmake"
2016-03-04 23:00:12 +00:00
DESTINATION ${INSTALL_CMAKE_DIR} COMPONENT athena)
2015-07-08 23:53:40 +00:00
# Install the export set for use with the install-tree
2016-03-04 23:00:12 +00:00
install(EXPORT AthenaTargets DESTINATION ${INSTALL_CMAKE_DIR} COMPONENT athena)
################
# atdna import #
################
2015-08-03 01:42:47 +00:00
add_subdirectory(atdna)
2018-02-27 06:02:24 +00:00
# Test target
add_executable(atdna-test atdna/test.cpp atdna/test.hpp)
target_atdna(atdna-test atdna_test.cpp atdna/test.hpp)
2018-09-25 22:38:11 +00:00
if (CMAKE_SYSTEM_NAME STREQUAL "Switch")
set_target_properties(atdna-test PROPERTIES SUFFIX ".elf")
target_link_libraries(atdna-test athena-core nx)
2018-09-25 22:38:11 +00:00
else()
target_link_libraries(atdna-test athena-core)
2015-10-16 08:07:54 +00:00
endif()
2015-07-08 23:53:40 +00: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 23:53:40 +00: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 23:00:12 +00: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 23:00:12 +00: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-07 03:23:37 +00:00