|
|
@ -3,16 +3,26 @@ project(klotski) |
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------------ # |
|
|
|
|
|
|
|
option(KLSK_ENABLE_LTO "Enable LTO optimisation of the project." OFF) |
|
|
|
option(KLSK_SHARED_LIB "Build klotski core as a dynamic library." OFF) |
|
|
|
option(KLSK_ENABLE_TESTING "Enable testing of the klotski project." ON) |
|
|
|
option(KLSK_ENABLE_BENCHMARK "Enable benchmark of the klotski project." ON) |
|
|
|
option(KLSK_ENABLE_LTO "Enable LTO optimisation of the project." ON) |
|
|
|
#option(KLSK_SHARED_LIB "Build klotski core as a dynamic library." OFF) |
|
|
|
option(KLSK_ENABLE_TESTING "Enable testing of the klotski project." OFF) |
|
|
|
option(KLSK_ENABLE_BENCHMARK "Enable benchmark of the klotski project." OFF) |
|
|
|
|
|
|
|
option(KLSK_C_FFI "" ON) |
|
|
|
option(KLSK_PYTHON_FFI "" ON) |
|
|
|
option(KLSK_RUST_FFI "" ON) |
|
|
|
option(KLSK_C_FFI "" OFF) |
|
|
|
option(KLSK_RUST_FFI "" OFF) |
|
|
|
option(KLSK_PYTHON_FFI "" OFF) |
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------------ # |
|
|
|
if (KLSK_DEV_MODE) |
|
|
|
set(KLSK_C_FFI ON) |
|
|
|
set(KLSK_RUST_FFI ON) |
|
|
|
set(KLSK_PYTHON_FFI ON) |
|
|
|
|
|
|
|
set(KLSK_ENABLE_LTO ON) |
|
|
|
set(KLSK_ENABLE_TESTING ON) |
|
|
|
set(KLSK_ENABLE_BENCHMARK ON) |
|
|
|
endif() |
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------------------- # |
|
|
|
|
|
|
|
if (NOT CMAKE_BUILD_TYPE) |
|
|
|
set(CMAKE_BUILD_TYPE Release) |
|
|
@ -20,17 +30,19 @@ endif() |
|
|
|
|
|
|
|
add_compile_options(-Wall -Wextra -g) |
|
|
|
|
|
|
|
# TODO: enabled by LTO option |
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") |
|
|
|
add_compile_options(-flto=full) |
|
|
|
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") |
|
|
|
if (KLSK_ENABLE_LTO) |
|
|
|
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") |
|
|
|
message(STATUS "klotski enable LTO for clang") |
|
|
|
add_compile_options(-flto=full) |
|
|
|
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") |
|
|
|
# add_compile_options(-flto=auto) |
|
|
|
else() |
|
|
|
#add_compile_options(-flto) # TODO: only for g++ |
|
|
|
message(FATAL_ERROR "unsupported compiler") # TODO: add MSVC support |
|
|
|
endif() |
|
|
|
endif() |
|
|
|
|
|
|
|
# TODO: for python-ffi |
|
|
|
if (SKBUILD) |
|
|
|
# TODO: add `KLSK_ENABLE_PIC` option |
|
|
|
if (SKBUILD) # for python-ffi |
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON) |
|
|
|
endif() |
|
|
|
|
|
|
@ -38,7 +50,7 @@ get_filename_component(KLSK_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR} ABSOLUTE) |
|
|
|
|
|
|
|
include(third_party/ThirdParty.cmake) |
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------------ # |
|
|
|
# ------------------------------------------------------------------------------------------- # |
|
|
|
|
|
|
|
#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin) |
|
|
|
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin) |
|
|
@ -51,4 +63,4 @@ include(third_party/ThirdParty.cmake) |
|
|
|
|
|
|
|
add_subdirectory(src) |
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------------ # |
|
|
|
# ------------------------------------------------------------------------------------------- # |
|
|
|