From f1215ee9f60bca1f52684bb44fa3cb2de6a7b0cf Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Sun, 9 Apr 2023 15:19:27 +0800 Subject: [PATCH] build: add abseil as submodule --- .gitmodules | 3 +++ CMakeLists.txt | 11 +++++++++++ src/CMakeLists.txt | 4 +++- src/klotski_core/CMakeLists.txt | 14 +------------- third_party/abseil-cpp | 1 + 5 files changed, 19 insertions(+), 14 deletions(-) create mode 160000 third_party/abseil-cpp diff --git a/.gitmodules b/.gitmodules index 3fe9bfd..67187a8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "third_party/tiny_thread_pool"] path = third_party/tiny_thread_pool url = https://github.com/dnomd343/tiny_thread_pool.git +[submodule "third_party/abseil-cpp"] + path = third_party/abseil-cpp + url = https://github.com/abseil/abseil-cpp.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d06c59..3c90cf7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,17 @@ file( FOLLOW_SYMLINK_CHAIN ) +################################################################################ + +option(BUILD_DYN "build shared klotski core library" OFF) +if (BUILD_DYN) + add_compile_options(-fPIC) +endif() + +set(ABSL_PROPAGATE_CXX_STD ON) +include_directories(third_party/abseil-cpp) +add_subdirectory(third_party/abseil-cpp) + add_subdirectory(src) ################################################################################ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fe9fc64..ca0dbd3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,4 +6,6 @@ add_subdirectory(klotski_core) include_directories(klotski_core) add_executable(cli main.c) -target_link_libraries(cli PRIVATE klotski) +target_link_libraries(cli PRIVATE klotski absl::flat_hash_map) + +# -labsl_hash -labsl_city -labsl_low_level_hash -labsl_raw_hash_set diff --git a/src/klotski_core/CMakeLists.txt b/src/klotski_core/CMakeLists.txt index 1c9dd2b..5aeda53 100644 --- a/src/klotski_core/CMakeLists.txt +++ b/src/klotski_core/CMakeLists.txt @@ -6,13 +6,6 @@ project(klotski-core VERSION 0.1.2 LANGUAGES CXX) ################################################################################ -option(BUILD_DYN "build shared klotski core library" OFF) -if (BUILD_DYN) - add_compile_options(-fPIC) -endif() - -################################################################################ - macro(git_tag _tag) find_package(Git QUIET) if (GIT_FOUND) @@ -104,10 +97,6 @@ include_directories(group) ################################################################################ -find_package(absl REQUIRED) - -################################################################################ - add_subdirectory(utils) add_subdirectory(all_cases) @@ -151,10 +140,9 @@ list(APPEND OBJS $) if (BUILD_DYN) add_library(klotski SHARED ${OBJS}) + target_link_libraries(klotski absl::flat_hash_map) else() add_library(klotski STATIC ${OBJS}) endif() -target_link_libraries(klotski absl::flat_hash_map) - ################################################################################ diff --git a/third_party/abseil-cpp b/third_party/abseil-cpp new file mode 160000 index 0000000..b971ac5 --- /dev/null +++ b/third_party/abseil-cpp @@ -0,0 +1 @@ +Subproject commit b971ac5250ea8de900eae9f95e06548d14cd95fe