mirror of
https://gitlab.com/manzerbredes/chess-move-interface.git
synced 2025-04-05 01:26:30 +02:00
29 lines
1 KiB
CMake
29 lines
1 KiB
CMake
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)
|
|
add_library(ChessMoveInterface OBJECT ${SRC_CPP_FILES})
|
|
target_include_directories(ChessMoveInterface PUBLIC ${CMI_INCLUDE_DIR})
|
|
endif()
|
|
|
|
# Unit tests
|
|
set(COMPILE_TESTS OFF CACHE BOOL "Should unit tests be compiled")
|
|
if(COMPILE_TESTS)
|
|
enable_testing()
|
|
add_subdirectory(./tests)
|
|
endif()
|