?login_element?

Subversion Repositories NedoOS

Rev

Rev 539 | Blame | Compare with Previous | Last modification | View Log | Download

  1. ##############################################################
  2. #
  3. # CMakeLists.txt - created by Cizo2000 <cizo2000@gmail.com>
  4. #
  5. ##############################################################
  6.  
  7. cmake_minimum_required(VERSION 3.9.6)
  8. set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
  9.  
  10. project(sjasmplus)
  11. set(MY_LUA_INCLUDE_DIR "lua5.4")
  12. set(MY_LUA_LIBRARY "lua5.4")
  13. set(LUABRIDGE_DIR "LuaBridge/Source")
  14. set(UNIT_TESTS_DIR "cpp-src-tests")
  15. set(UNITTESTPP_DIR "unittest-cpp")
  16.  
  17. set(SOURCES
  18.         sjasm/devices.cpp
  19.         sjasm/directives.cpp
  20.         sjasm/io_cpc.cpp
  21.         sjasm/io_err.cpp
  22.         sjasm/io_nex.cpp
  23.         sjasm/io_snapshots.cpp
  24.         sjasm/io_tape.cpp
  25.         sjasm/io_trd.cpp
  26.         sjasm/io_tzx.cpp
  27.         sjasm/lua_sjasm.cpp
  28.         sjasm/parser.cpp
  29.         sjasm/reader.cpp
  30.         sjasm/relocate.cpp
  31.         sjasm/sjasm.cpp
  32.         sjasm/sjio.cpp
  33.         sjasm/support.cpp
  34.         sjasm/tables.cpp
  35.         sjasm/z80.cpp
  36.         crc32c/crc32c.cpp
  37. )
  38.  
  39. add_definitions(-DMAX_PATH=PATH_MAX)
  40. add_definitions(-DCMAKE)
  41.  
  42. set(CMAKE_CXX_STANDARD 14)
  43. set(CMAKE_CXX_STANDARD_REQUIRED ON)
  44. set(CMAKE_CXX_EXTENSIONS ON)
  45.  
  46. set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall -pedantic")
  47. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -pedantic")
  48.  
  49. set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -s")
  50. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
  51.  
  52. option(ENABLE_LUA "Enable LUA scripting support" ON)
  53. option(SYSTEM_LUA "Use system LUA package" OFF)
  54. option(ADD_UNIT_TESTS "Add unit tests into binary" OFF)
  55.  
  56. if(ADD_UNIT_TESTS)
  57.         add_definitions(-DADD_UNIT_TESTS)
  58.         include_directories(${UNITTESTPP_DIR})
  59.         aux_source_directory(${UNITTESTPP_DIR}/UnitTest++/ UT_SRCS)
  60.         aux_source_directory(${UNITTESTPP_DIR}/UnitTest++/Posix/ UT_SRCS)
  61.         aux_source_directory(${UNIT_TESTS_DIR} UT_SRCS)
  62.         set(SOURCES
  63.                 ${SOURCES}
  64.                 ${UT_SRCS}
  65.         )
  66. endif(ADD_UNIT_TESTS)
  67.  
  68. if(ENABLE_LUA)
  69.         add_subdirectory(${LUABRIDGE_DIR})
  70.  
  71.         message(STATUS "Looking for Lua 5.4")
  72.  
  73.         if(SYSTEM_LUA)
  74.                 find_package(Lua "5.4" EXACT)
  75.         endif(SYSTEM_LUA)
  76.  
  77.         if(LUA_FOUND)
  78.                 message(STATUS "Looking for Lua 5.4 - found: ${LUA_LIBRARIES}")
  79.                 include_directories(${LUA_INCLUDE_DIR})
  80.         else(LUA_FOUND)
  81.                 message(STATUS "Looking for Lua 5.4 - using local")
  82.                 set(LUA_LIBRARY ${MY_LUA_LIBRARY})
  83.                 set(LUA_INCLUDE_DIR ${MY_LUA_INCLUDE_DIR})
  84.                 add_subdirectory(${LUA_INCLUDE_DIR})
  85.  
  86.                 target_include_directories(${MY_LUA_LIBRARY} PUBLIC
  87.             ${LUA_INCLUDE_DIR}
  88.                 )
  89.         endif(LUA_FOUND)
  90.  
  91.         add_definitions(-DUSE_LUA)
  92.  
  93.         if( ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
  94.                 add_definitions(-DLUA_USE_LINUX)
  95.         elseif(CYGWIN)
  96.                 add_definitions(-DLUA_USE_LINUX)
  97.         elseif(WIN32)
  98.         endif()
  99. endif(ENABLE_LUA)
  100.  
  101. include_directories(sjasm)
  102. include_directories(crc32c)
  103.  
  104. if(WIN32)
  105.         set(RESOURCES sjasmwin32/sjasmplus.rc)
  106. endif()
  107.  
  108. add_executable(${PROJECT_NAME} ${SOURCES} ${RESOURCES})
  109.  
  110. if(ENABLE_LUA)
  111.         target_link_libraries(
  112.                 ${PROJECT_NAME}
  113.                 ${LUA_LIBRARY}
  114.                 LuaBridge
  115.         )
  116.         if(NOT WIN32)
  117.                 find_package(LibDL)
  118.                 if(LIBDL_FOUND)
  119.                 target_link_libraries(
  120.                         ${PROJECT_NAME}
  121.                         ${LIBDL_LIBRARIES}
  122.                 )
  123.                 endif(LIBDL_FOUND)
  124.         endif()
  125. endif(ENABLE_LUA)
  126.  
  127. install(TARGETS ${PROJECT_NAME}
  128.         RUNTIME DESTINATION bin)
  129.  
  130. find_program(BASH_PROGRAM bash)
  131.  
  132. if(BASH_PROGRAM)
  133.         add_custom_target(tests COMMAND "EXE=${CMAKE_BINARY_DIR}/${PROJECT_NAME}" ${BASH_PROGRAM} "${CMAKE_SOURCE_DIR}/ContinuousIntegration/test_folder_tests.sh"
  134.                 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  135.                 DEPENDS ${PROJECT_NAME})
  136.  
  137.         add_custom_target(examples COMMAND "EXE=${CMAKE_BINARY_DIR}/${PROJECT_NAME}" ${BASH_PROGRAM} "${CMAKE_SOURCE_DIR}/ContinuousIntegration/test_folder_examples.sh"
  138.                 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
  139.                 DEPENDS ${PROJECT_NAME})
  140. endif()
  141.