#!/usr/bin/cmake cmake_minimum_required (VERSION 3.18) # ------------------------------------------------------------------------------------------------- project( Tangelo VERSION 2.3.0116 DESCRIPTION "Experimental extreme file compression algorithm" ) include("../../BuildSystem/cmake/cplusplus.cmake") set(BUILD_CMD OFF CACHE BOOL "Whether to build a command-line tangelo-cmd tool") # ------------------------------------------------------------------------------------------------- if(NOT EXISTS ${PROJECT_SOURCE_DIR}/downloads/tangelo-2.3.0116.7z) message(STATUS "Downloading Tangelo sources") file( DOWNLOAD https://encode.su/attachment.php?attachmentid=4030&d=1452576196 ${PROJECT_SOURCE_DIR}/downloads/tangelo-2.3.0116.7z SHOW_PROGRESS EXPECTED_HASH SHA256=eadb3f6c923aa6cc5049969d476d8c9b668bdbbc2907fb33c894ad872cc5fd0b ) endif() # ------------------------------------------------------------------------------------------------- if(NOT EXISTS ${PROJECT_SOURCE_DIR}/build) message(STATUS "Extracting Tangelo sources") file( ARCHIVE_EXTRACT INPUT ${PROJECT_SOURCE_DIR}/downloads/tangelo-2.3.0116.7z DESTINATION ${CMAKE_BINARY_DIR}/extract ) file( RENAME ${CMAKE_BINARY_DIR}/extract ${PROJECT_SOURCE_DIR}/build ) endif() # ------------------------------------------------------------------------------------------------- set( sourceFiles "build/tangelo_2_3_rev0116.cpp" ) set( headerFiles "" ) # ------------------------------------------------------------------------------------------------- add_library(Tangelo STATIC) add_library(Tangelo::Static ALIAS Tangelo) target_compile_definitions( Tangelo PUBLIC main=not_main ) target_include_directories( Tangelo PUBLIC "build" ) target_sources( Tangelo PUBLIC ${headerFiles} PRIVATE ${sourceFiles} ) #set_target_properties(Tangelo PROPERTIES PREFIX "") set_target_properties(Tangelo PROPERTIES OUTPUT_NAME "tangelo") # ------------------------------------------------------------------------------------------------- if(BUILD_CMD) add_executable(Tangelo-cmd) target_include_directories( Tangelo-cmd PUBLIC "build" ) target_sources( Tangelo-cmd PUBLIC ${headerFiles} PRIVATE ${sourceFiles} ) #set_target_properties(Tangelo-cmd PROPERTIES PREFIX "") set_target_properties(Tangelo-cmd PROPERTIES OUTPUT_NAME "tangelo-cmd") endif() # ------------------------------------------------------------------------------------------------- install( FILES ${headerFiles} DESTINATION ${PROJECT_SOURCE_DIR}/Include ) install( TARGETS Tangelo ARCHIVE DESTINATION ${PROJECT_SOURCE_DIR}/bin/${NUCLEX_COMPILER_TAG} ) if(BUILD_CMD) install( TARGETS Tangelo-cmd RUNTIME DESTINATION ${PROJECT_SOURCE_DIR}/bin/${NUCLEX_COMPILER_TAG} ) endif() # ------------------------------------------------------------------------------------------------- file( WRITE "${PROJECT_SOURCE_DIR}/TangeloConfig.cmake" "#!/usr/bin/cmake # Configuration to include Tangelo in a CMake-based project. If you want to # reference Tangelo as an externally compiled static library, do this: # # set(Tangelo_DIR \"../ThirdParty/Tangelo\") # find_package(Tangelo REQUIRED CONFIG) # # target_link_libraries( # MyAwesomeProject # PRIVATE Tangelo::Static # ) # # Alternatively, if you want to build Tangelo together with your project, # use the normal CMakeLists.txt with CMake's add_subdirectory() command: # # add_subdirectory( # \"\${PROJECT_SOURCE_DIR}/../ThirdParty/Tangelo\" # \"\${CMAKE_BINARY_DIR}/Tangelo\" # ) # # target_link_libraries( # MyAwesomeProject # PRIVATE Tangelo # ) # # ------------------------------------------------------------------------------------------------- if(NOT DEFINED NUCLEX_COMPILER_TAG) message( FATAL_ERROR \"NUCLEX_COMPILER_TAG not defined! Include cplusplus.cmake before importing this package \\ in order to generate a tag identifying the platform/compiler/architecture/variant!\" ) endif() # ------------------------------------------------------------------------------------------------- if(NOT EXISTS \"\${CMAKE_CURRENT_LIST_DIR}/bin/\${NUCLEX_COMPILER_TAG}\") # TODO: Warn and link release build when compiling in debug mode # TODO: Warn and link build for older compiler version if found message( FATAL_ERROR \"Directory '\${CMAKE_CURRENT_LIST_DIR}/bin/\${NUCLEX_COMPILER_TAG}' not found. \\ Please either build and install this project before importing it via \\ find_package() or use this project's main CMakeFiles.txt via add_subdirectory()!\" ) endif() # ------------------------------------------------------------------------------------------------- add_library(Tangelo::Static STATIC IMPORTED) # This may cause warnings on recent GCC versions (10.0.0+?) with LTO because GCC detects # that the headers used during build (residing in build/) are not the same used when # linking the library (copies resising in Include/). # # CMake doesn't run the install step during build, so the only way to get the headers # in place before building would be by copying them rather than installing them. set_target_properties( Tangelo::Static PROPERTIES INTERFACE_INCLUDE_DIRECTORIES \"\${CMAKE_CURRENT_LIST_DIR}/Include\" IMPORTED_LINK_INTERFACE_LANGUAGES \"C\" ) if(WIN32) set_target_properties( Tangelo::Static PROPERTIES IMPORTED_LOCATION \"\${CMAKE_CURRENT_LIST_DIR}/bin/\${NUCLEX_COMPILER_TAG}/tangelo.lib\" ) else() set_target_properties( Tangelo::Static PROPERTIES IMPORTED_LOCATION \"\${CMAKE_CURRENT_LIST_DIR}/bin/\${NUCLEX_COMPILER_TAG}/libtangelo.a\" ) endif() message(STATUS \"Imported Tangelo targets with binaries in '\${CMAKE_CURRENT_LIST_DIR}'\")" ) # -------------------------------------------------------------------------------------------------