From 53b1dac10907800c5d53a8da7d4e6561ee525ace Mon Sep 17 00:00:00 2001 From: jianda sheng Date: Tue, 8 Aug 2023 21:54:42 +0800 Subject: [PATCH 1/4] METIS/CMakeLists.txt require include_directories(${GKLIB_PATH}/include) change the directory of files --- CMakeLists.txt | 6 +++--- GKlibSystem.cmake | 4 ++-- GKlib.h => include/GKlib.h | 0 gk_arch.h => include/gk_arch.h | 0 gk_defs.h => include/gk_defs.h | 0 gk_externs.h => include/gk_externs.h | 0 gk_getopt.h => include/gk_getopt.h | 0 gk_macros.h => include/gk_macros.h | 0 gk_mkblas.h => include/gk_mkblas.h | 0 gk_mkmemory.h => include/gk_mkmemory.h | 0 gk_mkpqueue.h => include/gk_mkpqueue.h | 0 gk_mkpqueue2.h => include/gk_mkpqueue2.h | 0 gk_mkrandom.h => include/gk_mkrandom.h | 0 gk_mksort.h => include/gk_mksort.h | 0 gk_mkutils.h => include/gk_mkutils.h | 0 gk_ms_inttypes.h => include/gk_ms_inttypes.h | 0 gk_ms_stat.h => include/gk_ms_stat.h | 0 gk_ms_stdint.h => include/gk_ms_stdint.h | 0 gk_proto.h => include/gk_proto.h | 0 gk_struct.h => include/gk_struct.h | 0 gk_types.h => include/gk_types.h | 0 gkregex.h => include/gkregex.h | 0 {win32 => include/win32}/adapt.h | 0 b64.c => src/b64.c | 0 blas.c => src/blas.c | 0 cache.c => src/cache.c | 0 csr.c => src/csr.c | 0 error.c => src/error.c | 0 evaluate.c => src/evaluate.c | 0 fkvkselect.c => src/fkvkselect.c | 0 fs.c => src/fs.c | 0 getopt.c => src/getopt.c | 0 gk_util.c => src/gk_util.c | 0 gkregex.c => src/gkregex.c | 0 graph.c => src/graph.c | 0 htable.c => src/htable.c | 0 io.c => src/io.c | 0 itemsets.c => src/itemsets.c | 0 mcore.c => src/mcore.c | 0 memory.c => src/memory.c | 0 pqueue.c => src/pqueue.c | 0 random.c => src/random.c | 0 rw.c => src/rw.c | 0 seq.c => src/seq.c | 0 sort.c => src/sort.c | 0 string.c => src/string.c | 0 timers.c => src/timers.c | 0 tokenizer.c => src/tokenizer.c | 0 {win32 => src/win32}/adapt.c | 2 +- 49 files changed, 6 insertions(+), 6 deletions(-) rename GKlib.h => include/GKlib.h (100%) rename gk_arch.h => include/gk_arch.h (100%) rename gk_defs.h => include/gk_defs.h (100%) rename gk_externs.h => include/gk_externs.h (100%) rename gk_getopt.h => include/gk_getopt.h (100%) rename gk_macros.h => include/gk_macros.h (100%) rename gk_mkblas.h => include/gk_mkblas.h (100%) rename gk_mkmemory.h => include/gk_mkmemory.h (100%) rename gk_mkpqueue.h => include/gk_mkpqueue.h (100%) rename gk_mkpqueue2.h => include/gk_mkpqueue2.h (100%) rename gk_mkrandom.h => include/gk_mkrandom.h (100%) rename gk_mksort.h => include/gk_mksort.h (100%) rename gk_mkutils.h => include/gk_mkutils.h (100%) rename gk_ms_inttypes.h => include/gk_ms_inttypes.h (100%) rename gk_ms_stat.h => include/gk_ms_stat.h (100%) rename gk_ms_stdint.h => include/gk_ms_stdint.h (100%) rename gk_proto.h => include/gk_proto.h (100%) rename gk_struct.h => include/gk_struct.h (100%) rename gk_types.h => include/gk_types.h (100%) rename gkregex.h => include/gkregex.h (100%) rename {win32 => include/win32}/adapt.h (100%) rename b64.c => src/b64.c (100%) rename blas.c => src/blas.c (100%) rename cache.c => src/cache.c (100%) rename csr.c => src/csr.c (100%) rename error.c => src/error.c (100%) rename evaluate.c => src/evaluate.c (100%) rename fkvkselect.c => src/fkvkselect.c (100%) rename fs.c => src/fs.c (100%) rename getopt.c => src/getopt.c (100%) rename gk_util.c => src/gk_util.c (100%) rename gkregex.c => src/gkregex.c (100%) rename graph.c => src/graph.c (100%) rename htable.c => src/htable.c (100%) rename io.c => src/io.c (100%) rename itemsets.c => src/itemsets.c (100%) rename mcore.c => src/mcore.c (100%) rename memory.c => src/memory.c (100%) rename pqueue.c => src/pqueue.c (100%) rename random.c => src/random.c (100%) rename rw.c => src/rw.c (100%) rename seq.c => src/seq.c (100%) rename sort.c => src/sort.c (100%) rename string.c => src/string.c (100%) rename timers.c => src/timers.c (100%) rename tokenizer.c => src/tokenizer.c (100%) rename {win32 => src/win32}/adapt.c (85%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9cd1b4b..153fb3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,15 +8,15 @@ set(GKLIB_PATH ${abs}) unset(abs) include(GKlibSystem.cmake) -include_directories(".") +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) if(MSVC) include_directories("win32") - file(GLOB win32_sources RELATIVE "win32" "*.c") + file(GLOB win32_sources "include/win32/*.h" "src/win32/*.c") else(MSVC) set(win32_sources, "") endif(MSVC) -add_library(GKlib ${GKlib_sources} ${win32_sources}) +add_library(GKlib ${GKlib_includes} ${GKlib_sources} ${win32_sources}) if(UNIX) target_link_libraries(GKlib m) diff --git a/GKlibSystem.cmake b/GKlibSystem.cmake index 31a1cf1..5de9187 100644 --- a/GKlibSystem.cmake +++ b/GKlibSystem.cmake @@ -148,5 +148,5 @@ endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GKlib_COPTIONS} ${GKlib_COPTS}") # Find GKlib sources. -file(GLOB GKlib_sources ${GKLIB_PATH}/*.c) -file(GLOB GKlib_includes ${GKLIB_PATH}/*.h) +file(GLOB GKlib_sources ${GKLIB_PATH}/src/*.c) +file(GLOB GKlib_includes ${GKLIB_PATH}/include/*.h) diff --git a/GKlib.h b/include/GKlib.h similarity index 100% rename from GKlib.h rename to include/GKlib.h diff --git a/gk_arch.h b/include/gk_arch.h similarity index 100% rename from gk_arch.h rename to include/gk_arch.h diff --git a/gk_defs.h b/include/gk_defs.h similarity index 100% rename from gk_defs.h rename to include/gk_defs.h diff --git a/gk_externs.h b/include/gk_externs.h similarity index 100% rename from gk_externs.h rename to include/gk_externs.h diff --git a/gk_getopt.h b/include/gk_getopt.h similarity index 100% rename from gk_getopt.h rename to include/gk_getopt.h diff --git a/gk_macros.h b/include/gk_macros.h similarity index 100% rename from gk_macros.h rename to include/gk_macros.h diff --git a/gk_mkblas.h b/include/gk_mkblas.h similarity index 100% rename from gk_mkblas.h rename to include/gk_mkblas.h diff --git a/gk_mkmemory.h b/include/gk_mkmemory.h similarity index 100% rename from gk_mkmemory.h rename to include/gk_mkmemory.h diff --git a/gk_mkpqueue.h b/include/gk_mkpqueue.h similarity index 100% rename from gk_mkpqueue.h rename to include/gk_mkpqueue.h diff --git a/gk_mkpqueue2.h b/include/gk_mkpqueue2.h similarity index 100% rename from gk_mkpqueue2.h rename to include/gk_mkpqueue2.h diff --git a/gk_mkrandom.h b/include/gk_mkrandom.h similarity index 100% rename from gk_mkrandom.h rename to include/gk_mkrandom.h diff --git a/gk_mksort.h b/include/gk_mksort.h similarity index 100% rename from gk_mksort.h rename to include/gk_mksort.h diff --git a/gk_mkutils.h b/include/gk_mkutils.h similarity index 100% rename from gk_mkutils.h rename to include/gk_mkutils.h diff --git a/gk_ms_inttypes.h b/include/gk_ms_inttypes.h similarity index 100% rename from gk_ms_inttypes.h rename to include/gk_ms_inttypes.h diff --git a/gk_ms_stat.h b/include/gk_ms_stat.h similarity index 100% rename from gk_ms_stat.h rename to include/gk_ms_stat.h diff --git a/gk_ms_stdint.h b/include/gk_ms_stdint.h similarity index 100% rename from gk_ms_stdint.h rename to include/gk_ms_stdint.h diff --git a/gk_proto.h b/include/gk_proto.h similarity index 100% rename from gk_proto.h rename to include/gk_proto.h diff --git a/gk_struct.h b/include/gk_struct.h similarity index 100% rename from gk_struct.h rename to include/gk_struct.h diff --git a/gk_types.h b/include/gk_types.h similarity index 100% rename from gk_types.h rename to include/gk_types.h diff --git a/gkregex.h b/include/gkregex.h similarity index 100% rename from gkregex.h rename to include/gkregex.h diff --git a/win32/adapt.h b/include/win32/adapt.h similarity index 100% rename from win32/adapt.h rename to include/win32/adapt.h diff --git a/b64.c b/src/b64.c similarity index 100% rename from b64.c rename to src/b64.c diff --git a/blas.c b/src/blas.c similarity index 100% rename from blas.c rename to src/blas.c diff --git a/cache.c b/src/cache.c similarity index 100% rename from cache.c rename to src/cache.c diff --git a/csr.c b/src/csr.c similarity index 100% rename from csr.c rename to src/csr.c diff --git a/error.c b/src/error.c similarity index 100% rename from error.c rename to src/error.c diff --git a/evaluate.c b/src/evaluate.c similarity index 100% rename from evaluate.c rename to src/evaluate.c diff --git a/fkvkselect.c b/src/fkvkselect.c similarity index 100% rename from fkvkselect.c rename to src/fkvkselect.c diff --git a/fs.c b/src/fs.c similarity index 100% rename from fs.c rename to src/fs.c diff --git a/getopt.c b/src/getopt.c similarity index 100% rename from getopt.c rename to src/getopt.c diff --git a/gk_util.c b/src/gk_util.c similarity index 100% rename from gk_util.c rename to src/gk_util.c diff --git a/gkregex.c b/src/gkregex.c similarity index 100% rename from gkregex.c rename to src/gkregex.c diff --git a/graph.c b/src/graph.c similarity index 100% rename from graph.c rename to src/graph.c diff --git a/htable.c b/src/htable.c similarity index 100% rename from htable.c rename to src/htable.c diff --git a/io.c b/src/io.c similarity index 100% rename from io.c rename to src/io.c diff --git a/itemsets.c b/src/itemsets.c similarity index 100% rename from itemsets.c rename to src/itemsets.c diff --git a/mcore.c b/src/mcore.c similarity index 100% rename from mcore.c rename to src/mcore.c diff --git a/memory.c b/src/memory.c similarity index 100% rename from memory.c rename to src/memory.c diff --git a/pqueue.c b/src/pqueue.c similarity index 100% rename from pqueue.c rename to src/pqueue.c diff --git a/random.c b/src/random.c similarity index 100% rename from random.c rename to src/random.c diff --git a/rw.c b/src/rw.c similarity index 100% rename from rw.c rename to src/rw.c diff --git a/seq.c b/src/seq.c similarity index 100% rename from seq.c rename to src/seq.c diff --git a/sort.c b/src/sort.c similarity index 100% rename from sort.c rename to src/sort.c diff --git a/string.c b/src/string.c similarity index 100% rename from string.c rename to src/string.c diff --git a/timers.c b/src/timers.c similarity index 100% rename from timers.c rename to src/timers.c diff --git a/tokenizer.c b/src/tokenizer.c similarity index 100% rename from tokenizer.c rename to src/tokenizer.c diff --git a/win32/adapt.c b/src/win32/adapt.c similarity index 85% rename from win32/adapt.c rename to src/win32/adapt.c index 546857c..d56f767 100644 --- a/win32/adapt.c +++ b/src/win32/adapt.c @@ -3,7 +3,7 @@ \brief Implementation of Win32 adaptation of libc functions */ -#include "adapt.h" +#include "win32/adapt.h" pid_t getpid(void) { From cb4fe3b44b6c17979320621057c8a120d2bbb0ab Mon Sep 17 00:00:00 2001 From: jianda sheng Date: Tue, 8 Aug 2023 22:44:13 +0800 Subject: [PATCH 2/4] GKLib can build as git submodule without the conflict of options. --- CMakeLists.txt | 9 ++++--- GKlibSystem.cmake | 68 +++++++++++++++++++++++------------------------ 2 files changed, 40 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 153fb3f..daa4785 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,8 @@ cmake_minimum_required(VERSION 2.8) project(GKlib C) -option(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" OFF) +option(GKLIB_BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" OFF) +option(GKLIB_BUILD_TEST "Build test projects" FALSE) get_filename_component(abs "." ABSOLUTE) set(GKLIB_PATH ${abs}) @@ -22,8 +23,10 @@ if(UNIX) target_link_libraries(GKlib m) endif(UNIX) -include_directories("test") -add_subdirectory("test") +if(${GKLIB_BUILD_TEST}) + include_directories("test") + add_subdirectory("test") +endif() install(TARGETS GKlib ARCHIVE DESTINATION lib/${LINSTALL_PATH} diff --git a/GKlibSystem.cmake b/GKlibSystem.cmake index 5de9187..b1efc6a 100644 --- a/GKlibSystem.cmake +++ b/GKlibSystem.cmake @@ -3,17 +3,17 @@ include(CheckFunctionExists) include(CheckIncludeFile) # Setup options. -option(GDB "enable use of GDB" OFF) -option(ASSERT "turn asserts on" OFF) -option(ASSERT2 "additional assertions" OFF) -option(DEBUG "add debugging support" OFF) -option(GPROF "add gprof support" OFF) -option(VALGRIND "add valgrind support" OFF) -option(OPENMP "enable OpenMP support" OFF) -option(PCRE "enable PCRE support" OFF) -option(GKREGEX "enable GKREGEX support" OFF) -option(GKRAND "enable GKRAND support" OFF) -option(NO_X86 "enable NO_X86 support" OFF) +option(GKLIB_GDB "enable use of GDB" OFF) +option(GKLIB_ASSERT "turn asserts on" OFF) +option(GKLIB_ASSERT2 "additional assertions" OFF) +option(GKLIB_DEBUG "add debugging support" OFF) +option(GKLIB_GPROF "add gprof support" OFF) +option(GKLIB_VALGRIND "add valgrind support" OFF) +option(GKLIB_OPENMP "enable OpenMP support" OFF) +option(GKLIB_PCRE "enable PCRE support" OFF) +option(GKLIB_GKREGEX "enable GKREGEX support" OFF) +option(GKLIB_GKRAND "enable GKRAND support" OFF) +option(GKLIB_NO_X86 "enable NO_X86 support" OFF) # Add compiler flags. @@ -31,7 +31,7 @@ endif(CYGWIN) if(CMAKE_COMPILER_IS_GNUCC) # GCC opts. set(GKlib_COPTIONS "${GKlib_COPTIONS} -std=c99 -fno-strict-aliasing") -if(VALGRIND) +if(GKLIB_VALGRIND) set(GKlib_COPTIONS "${GK_COPTIONS} -march=x86-64 -mtune=generic") else() # -march=native is not a valid flag on PPC: @@ -40,7 +40,7 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "power|ppc|powerpc|ppc64|powerpc64" OR (APPLE else() set(GKlib_COPTIONS "${GKlib_COPTIONS} -march=native") endif() -endif(VALGRIND) +endif(GKLIB_VALGRIND) if(NOT MINGW) set(GKlib_COPTIONS "${GKlib_COPTIONS} -fPIC") endif(NOT MINGW) @@ -57,59 +57,59 @@ if(${CMAKE_C_COMPILER_ID} MATCHES "Intel") endif() # Find OpenMP if it is requested. -if(OPENMP) +if(GKLIB_OPENMP) include(FindOpenMP) if(OPENMP_FOUND) set(GKlib_COPTIONS "${GKlib_COPTIONS} -D__OPENMP__ ${OpenMP_C_FLAGS}") else() message(WARNING "OpenMP was requested but support was not found") endif(OPENMP_FOUND) -endif(OPENMP) +endif(GKLIB_OPENMP) # Set the CPU type -if(NO_X86) - set(GKlib_COPTIONS "${GKlib_COPTIONS} -DNO_X86=${NO_X86}") -endif(NO_X86) +if(GKLIB_NO_X86) + set(GKlib_COPTIONS "${GKlib_COPTIONS} -DNO_X86=${GKLIB_NO_X86}") +endif(GKLIB_NO_X86) # Add various definitions. -if(GDB) +if(GKLIB_GDB) set(GKlib_COPTS "${GKlib_COPTS} -g") set(GKlib_COPTIONS "${GKlib_COPTIONS} -Werror") else() set(GKlib_COPTS "-O3") -endif(GDB) +endif(GKLIB_GDB) -if(DEBUG) +if(GKLIB_DEBUG) set(GKlib_COPTS "-g") set(GKlib_COPTIONS "${GKlib_COPTIONS} -DDEBUG") -endif(DEBUG) +endif(GKLIB_DEBUG) -if(GPROF) +if(GKLIB_GPROF) set(GKlib_COPTS "-pg") -endif(GPROF) +endif(GKLIB_GPROF) -if(NOT ASSERT) +if(NOT GKLIB_ASSERT) set(GKlib_COPTIONS "${GKlib_COPTIONS} -DNDEBUG") -endif(NOT ASSERT) +endif(NOT GKLIB_ASSERT) -if(NOT ASSERT2) +if(NOT GKLIB_ASSERT2) set(GKlib_COPTIONS "${GKlib_COPTIONS} -DNDEBUG2") -endif(NOT ASSERT2) +endif(NOT GKLIB_ASSERT2) # Add various options -if(PCRE) +if(GKLIB_PCRE) set(GKlib_COPTIONS "${GKlib_COPTIONS} -D__WITHPCRE__") -endif(PCRE) +endif(GKLIB_PCRE) -if(GKREGEX) +if(GKLIB_GKREGEX) set(GKlib_COPTIONS "${GKlib_COPTIONS} -DUSE_GKREGEX") -endif(GKREGEX) +endif(GKLIB_GKREGEX) -if(GKRAND) +if(GKLIB_GKRAND) set(GKlib_COPTIONS "${GKlib_COPTIONS} -DUSE_GKRAND") -endif(GKRAND) +endif(GKLIB_GKRAND) # Check for features. From 59963ed05098733281b535c453d16d6cf5db4b62 Mon Sep 17 00:00:00 2001 From: jianda sheng Date: Thu, 10 Aug 2023 00:02:12 +0800 Subject: [PATCH 3/4] change GKLIB_BUILD_TEST default ON --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index daa4785..d297842 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8) project(GKlib C) option(GKLIB_BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" OFF) -option(GKLIB_BUILD_TEST "Build test projects" FALSE) +option(GKLIB_BUILD_TEST "Build test projects" ON) get_filename_component(abs "." ABSOLUTE) set(GKLIB_PATH ${abs}) From d456681a35ce8e9e9c5c9b4e9f8745a9293fb17f Mon Sep 17 00:00:00 2001 From: jianda sheng Date: Thu, 10 Aug 2023 00:45:27 +0800 Subject: [PATCH 4/4] add GKLIB_NAME which can help metis find the lib is used as git submodule --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d297842..0c8c816 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,7 @@ cmake_minimum_required(VERSION 2.8) project(GKlib C) +set(GKLIB_NAME "GKlib" CACHE INTERNAL "") option(GKLIB_BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" OFF) option(GKLIB_BUILD_TEST "Build test projects" ON) @@ -17,7 +18,11 @@ else(MSVC) set(win32_sources, "") endif(MSVC) -add_library(GKlib ${GKlib_includes} ${GKlib_sources} ${win32_sources}) +if(GKLIB_BUILD_SHARED_LIBS) + add_library(${GKLIB_NAME} SHARED ${GKlib_includes} ${GKlib_sources} ${win32_sources}) +else() + add_library(${GKLIB_NAME} STATIC ${GKlib_includes} ${GKlib_sources} ${win32_sources}) +endif() if(UNIX) target_link_libraries(GKlib m)