diff --git a/CMakeLists.txt b/CMakeLists.txt index 9cd1b4b..0c8c816 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,29 +1,37 @@ 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) +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) get_filename_component(abs "." ABSOLUTE) 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}) +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) 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 31a1cf1..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. @@ -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) {