chess-move-interface/CMakeLists.txt

30 lines
1 KiB
Text
Raw Permalink Normal View History

2023-01-18 21:53:37 +01:00
cmake_minimum_required(VERSION 3.18)
project(ChessMoveInterface)
# Includes
set(CMI_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/includes) # For conveniance
set(CMI_INCLUDE_DIR ${CMI_INCLUDE_DIR} PARENT_SCOPE) # To be used by other projects with add_subdirectory()
file(MAKE_DIRECTORY ${CMI_INCLUDE_DIR})
# Copy all includes
file(GLOB_RECURSE HEADER_FILES src/*.hpp)
foreach(FILE ${HEADER_FILES})
file(RELATIVE_PATH FILE_SUBDIR ${CMAKE_CURRENT_SOURCE_DIR}/src ${FILE})
configure_file(${FILE} ${CMI_INCLUDE_DIR}/${FILE_SUBDIR} COPYONLY)
endforeach(FILE ${HEADER_FILES})
# Add target if not exists
# This way ChessMoveInterface can be used in multiple submodules
file(GLOB_RECURSE SRC_CPP_FILES src/*.cpp)
if(NOT TARGET ChessMoveInterface)
2025-03-18 14:05:18 +01:00
add_library(ChessMoveInterface OBJECT ${SRC_CPP_FILES})
target_include_directories(ChessMoveInterface PUBLIC ${CMI_INCLUDE_DIR})
2023-01-19 10:09:07 +01:00
endif()
# Unit tests
2023-01-19 13:31:09 +01:00
set(COMPILE_TESTS OFF CACHE BOOL "Should unit tests be compiled")
if(COMPILE_TESTS)
2025-03-18 14:05:18 +01:00
enable_testing()
add_subdirectory(./tests)
endif()