mirror of https://github.com/dnomd343/klotski.git
Dnomd343
9 months ago
6 changed files with 81 additions and 114 deletions
@ -1,47 +1,37 @@ |
|||||
cmake_minimum_required(VERSION 3.0) |
cmake_minimum_required(VERSION 3.12) |
||||
|
|
||||
project(klotski) |
project(klotski) |
||||
|
|
||||
if(NOT CMAKE_BUILD_TYPE) |
# ------------------------------------------------------------------------------------ # |
||||
set(CMAKE_BUILD_TYPE Release) |
|
||||
endif() |
|
||||
|
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") |
|
||||
|
|
||||
get_filename_component(KLOTSKI_ROOT ${CMAKE_CURRENT_SOURCE_DIR} ABSOLUTE) |
option(KLOTSKI_ENABLE_LTO "Enable LTO optimisation of the project." OFF) |
||||
|
option(KLOTSKI_SHARED_LIB "Build klotski core as a dynamic library." OFF) |
||||
|
option(KLOTSKI_ENABLE_TESTING "Enable testing of the klotski project." ON) |
||||
|
option(KLOTSKI_ENABLE_BENCHMARK "Enable benchmark of the klotski project." ON) |
||||
|
|
||||
set(KLOTSKI_UNIT_TEST ON) |
# ------------------------------------------------------------------------------------ # |
||||
|
|
||||
include(third_party/third_party.cmake) |
if (NOT CMAKE_BUILD_TYPE) |
||||
|
set(CMAKE_BUILD_TYPE Release) |
||||
|
endif() |
||||
|
|
||||
################################################################################ |
add_compile_options(-Wall -Wextra) |
||||
|
add_compile_options(-flto) # TODO: enabled by LTO option |
||||
|
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin) |
get_filename_component(KLOTSKI_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR} ABSOLUTE) |
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin) |
|
||||
|
|
||||
file( |
include(third_party/ThirdParty.cmake) |
||||
COPY ${PROJECT_SOURCE_DIR}/src/klotski_core/klotski.h |
|
||||
DESTINATION ${PROJECT_SOURCE_DIR}/bin |
|
||||
FOLLOW_SYMLINK_CHAIN |
|
||||
) |
|
||||
|
|
||||
################################################################################ |
# ------------------------------------------------------------------------------------ # |
||||
|
|
||||
option(BUILD_DYN "build shared klotski core library" OFF) |
#set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin) |
||||
if (BUILD_DYN) |
#set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin) |
||||
add_compile_options(-fPIC) |
|
||||
endif() |
|
||||
|
|
||||
|
#file( |
||||
|
# COPY ${PROJECT_SOURCE_DIR}/src/klotski_core/klotski.h |
||||
|
# DESTINATION ${PROJECT_SOURCE_DIR}/bin |
||||
|
# FOLLOW_SYMLINK_CHAIN |
||||
|
#) |
||||
|
|
||||
add_subdirectory(src) |
add_subdirectory(src) |
||||
|
|
||||
################################################################################ |
# ------------------------------------------------------------------------------------ # |
||||
|
|
||||
#option(CORE_TEST "build test for klotski core" ON) |
|
||||
#if (CORE_TEST) |
|
||||
# include_directories(third_party/googletest/googletest/include) |
|
||||
# add_subdirectory(third_party/googletest EXCLUDE_FROM_ALL) |
|
||||
# add_subdirectory(test) |
|
||||
#endif() |
|
||||
|
|
||||
################################################################################ |
|
||||
|
@ -1,17 +1,13 @@ |
|||||
cmake_minimum_required(VERSION 3.0) |
cmake_minimum_required(VERSION 3.12) |
||||
|
|
||||
project(klotski-cli LANGUAGES C) |
|
||||
|
|
||||
add_subdirectory(core) |
add_subdirectory(core) |
||||
add_subdirectory(core_test) |
add_subdirectory(core_test) |
||||
|
|
||||
#add_subdirectory(klotski_core) |
#project(klotski-cli LANGUAGES C) |
||||
#include_directories(klotski_core) |
#set(CMAKE_C_STANDARD 90) |
||||
|
|
||||
set(CMAKE_C_STANDARD 90) |
|
||||
|
|
||||
add_executable(klotski_cli main.c) |
#add_executable(klotski_cli main.c) |
||||
target_link_libraries(klotski_cli PRIVATE klotski-core) |
#target_link_libraries(klotski_cli PRIVATE klotski-core) |
||||
#target_link_libraries(klotski_cli PRIVATE klotski absl::flat_hash_map) |
#target_link_libraries(klotski_cli PRIVATE klotski absl::flat_hash_map) |
||||
|
|
||||
# -labsl_hash -labsl_city -labsl_low_level_hash -labsl_raw_hash_set |
# -labsl_hash -labsl_city -labsl_low_level_hash -labsl_raw_hash_set |
||||
|
@ -0,0 +1,34 @@ |
|||||
|
set(KLOTSKI_THIRD_PARTY ${KLOTSKI_ROOT_DIR}/third_party) |
||||
|
|
||||
|
# abseil library |
||||
|
set(ABSL_PROPAGATE_CXX_STD ON) |
||||
|
add_subdirectory(${KLOTSKI_THIRD_PARTY}/abseil-cpp EXCLUDE_FROM_ALL) |
||||
|
|
||||
|
if (KLOTSKI_ENABLE_BENCHMARK) |
||||
|
# google benchmark framework |
||||
|
set(BENCHMARK_ENABLE_TESTING OFF) |
||||
|
set(BENCHMARK_ENABLE_EXCEPTIONS OFF) |
||||
|
add_subdirectory(${KLOTSKI_THIRD_PARTY}/benchmark EXCLUDE_FROM_ALL) |
||||
|
endif() |
||||
|
|
||||
|
if (KLOTSKI_ENABLE_TESTING) |
||||
|
# BS thread pool |
||||
|
add_library(thread_pool INTERFACE) |
||||
|
target_include_directories(thread_pool INTERFACE |
||||
|
${KLOTSKI_THIRD_PARTY}/thread-pool/include) |
||||
|
add_library(bs::thread_pool ALIAS thread_pool) |
||||
|
|
||||
|
# md5sum implementation |
||||
|
add_subdirectory(${KLOTSKI_THIRD_PARTY}/md5sum EXCLUDE_FROM_ALL) |
||||
|
target_include_directories(md5sum INTERFACE ${KLOTSKI_THIRD_PARTY}/md5sum) |
||||
|
|
||||
|
# google test framework |
||||
|
add_subdirectory(${KLOTSKI_THIRD_PARTY}/googletest EXCLUDE_FROM_ALL) |
||||
|
|
||||
|
# xxHash implementation |
||||
|
set(BUILD_SHARED_LIBS OFF) |
||||
|
set(XXHASH_BUILD_XXHSUM OFF) |
||||
|
set(XXHASH_BUILD_ENABLE_INLINE_API ON) |
||||
|
add_subdirectory(${KLOTSKI_THIRD_PARTY}/xxHash/cmake_unofficial EXCLUDE_FROM_ALL) |
||||
|
target_include_directories(xxhash INTERFACE ${KLOTSKI_THIRD_PARTY}/xxHash) |
||||
|
endif() |
@ -1,26 +0,0 @@ |
|||||
set(KLOTSKI_THIRD_PARTY ${KLOTSKI_ROOT}/third_party) |
|
||||
|
|
||||
set(ABSL_PROPAGATE_CXX_STD ON) |
|
||||
include_directories(abseil-cpp) |
|
||||
add_subdirectory(${KLOTSKI_THIRD_PARTY}/abseil-cpp EXCLUDE_FROM_ALL) |
|
||||
|
|
||||
if (KLOTSKI_UNIT_TEST) |
|
||||
include_directories(${KLOTSKI_THIRD_PARTY}/md5sum) |
|
||||
add_subdirectory(${KLOTSKI_THIRD_PARTY}/md5sum EXCLUDE_FROM_ALL) |
|
||||
endif (KLOTSKI_UNIT_TEST) |
|
||||
|
|
||||
if (KLOTSKI_UNIT_TEST) |
|
||||
include_directories(${KLOTSKI_THIRD_PARTY}/googletest/googletest/include) |
|
||||
add_subdirectory(${KLOTSKI_THIRD_PARTY}/googletest EXCLUDE_FROM_ALL) |
|
||||
endif (KLOTSKI_UNIT_TEST) |
|
||||
|
|
||||
if (KLOTSKI_UNIT_TEST) |
|
||||
include_directories(${KLOTSKI_THIRD_PARTY}/thread-pool/include) |
|
||||
endif (KLOTSKI_UNIT_TEST) |
|
||||
|
|
||||
if (KLOTSKI_UNIT_TEST) |
|
||||
set(XXHASH_BUILD_XXHSUM OFF) |
|
||||
set(XXHASH_BUILD_ENABLE_INLINE_API OFF) |
|
||||
include_directories(${KLOTSKI_THIRD_PARTY}/xxHash) |
|
||||
add_subdirectory(${KLOTSKI_THIRD_PARTY}/xxHash/cmake_unofficial EXCLUDE_FROM_ALL) |
|
||||
endif (KLOTSKI_UNIT_TEST) |
|
Loading…
Reference in new issue