|
| 1 | +cmake_minimum_required(VERSION 3.7) |
| 2 | +project(spasm-ng |
| 3 | + HOMEPAGE_URL https://github.com/alberthdev/spasm-ng |
| 4 | +) |
| 5 | + |
| 6 | +add_compile_options(-Wall) |
| 7 | + |
| 8 | +add_executable( |
| 9 | + spasm |
| 10 | + main.cpp opcodes.cpp pass_one.cpp pass_two.cpp utils.cpp |
| 11 | + export.cpp preop.cpp directive.cpp console.cpp expand_buf.cpp |
| 12 | + hash.cpp list.cpp parser.cpp storage.cpp errors.cpp bitmap.cpp |
| 13 | + modp_ascii.cpp opcodes_ez80.cpp |
| 14 | +) |
| 15 | +target_link_libraries(spasm m) |
| 16 | + |
| 17 | +# https://github.com/alberthdev/spasm-ng/issues/73 |
| 18 | +set_property(TARGET spasm PROPERTY CXX_STANDARD 11) |
| 19 | + |
| 20 | +set(ENABLE_APP_SIGNING ON CACHE BOOL "Enable support for signing applications") |
| 21 | +if (ENABLE_APP_SIGNING) |
| 22 | + find_package(PkgConfig REQUIRED) |
| 23 | + pkg_check_modules(gmp REQUIRED IMPORTED_TARGET gmp) |
| 24 | + find_package(OpenSSL |
| 25 | + REQUIRED |
| 26 | + COMPONENTS Crypto) |
| 27 | + target_link_libraries(spasm OpenSSL::Crypto PkgConfig::gmp) |
| 28 | +else() |
| 29 | + add_compile_definitions(NO_APPSIGN) |
| 30 | +endif() |
| 31 | + |
| 32 | +set(ENABLE_DEBUG_PRINT OFF CACHE BOOL "Enable additional debug messages") |
| 33 | +if (ENABLE_DEBUG_PRINT) |
| 34 | + add_compile_definitions(DEBUG_PRINT) |
| 35 | +endif() |
| 36 | + |
| 37 | +add_compile_definitions( |
| 38 | + USE_REUSABLES |
| 39 | + USE_BUILTIN_FCREATE |
| 40 | +) |
| 41 | +if (NOT WIN32) |
| 42 | + add_compile_definitions(UNIXVER) |
| 43 | +endif() |
| 44 | + |
| 45 | +# Version generation |
| 46 | +find_package(Git) |
| 47 | +if (Git_FOUND) |
| 48 | + execute_process( |
| 49 | + COMMAND "${GIT_EXECUTABLE}" describe --always --dirty |
| 50 | + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" |
| 51 | + RESULT_VARIABLE res |
| 52 | + OUTPUT_VARIABLE GIT_TREE_DESC |
| 53 | + ERROR_QUIET |
| 54 | + OUTPUT_STRIP_TRAILING_WHITESPACE |
| 55 | + ) |
| 56 | +else() |
| 57 | + set(GIT_TREE_DESC "unknown") |
| 58 | +endif() |
| 59 | +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.h.in" "${CMAKE_CURRENT_BINARY_DIR}/version.h") |
| 60 | +target_include_directories(spasm |
| 61 | + PRIVATE "${CMAKE_CURRENT_BINARY_DIR}" |
| 62 | +) |
| 63 | +# Trick from https://cmake.org/pipermail/cmake/2018-October/068389.html |
| 64 | +# to force a reconfigure on git change so the version string is always up to date |
| 65 | +set_property(GLOBAL APPEND |
| 66 | + PROPERTY CMAKE_CONFIGURE_DEPENDS |
| 67 | + "${CMAKE_SOURCE_DIR}/.git/index" |
| 68 | +) |
| 69 | + |
| 70 | +# Tests |
| 71 | +include(CTest) |
| 72 | +add_subdirectory(${PROJECT_SOURCE_DIR}/tests) |
| 73 | + |
| 74 | +# Install target |
| 75 | +include(GNUInstallDirs) |
| 76 | +install(TARGETS spasm) |
| 77 | +install(FILES README.md LICENSE |
| 78 | + DESTINATION ${CMAKE_INSTALL_DOCDIR}/spasm |
| 79 | +) |
| 80 | +file(GLOB include_files "inc/*.inc") |
| 81 | +install(FILES ${include_files} |
| 82 | + DESTINATION ${CMAKE_INSTALL_DATADIR}/spasm/inc |
| 83 | +) |
| 84 | + |
| 85 | +# Distribution packaging |
| 86 | +set(CPACK_PACKAGE_VERSION "${GIT_TREE_DESC}") |
| 87 | +set(CPACK_PACKAGE_DESCRIPTION "SPASM-ng is a z80 assembler with extra features to support development for TI calculators.") |
| 88 | +set(CPACK_PACKAGE_CONTACT "alberthdev@users.noreply.github.com") |
| 89 | +set(CPACK_DEBIAN_PACKAGE_DEPENDS "zlib1g, libssl1.0.0, libgmp10") |
| 90 | +include(CPack) |
0 commit comments