Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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}
Expand Down
72 changes: 36 additions & 36 deletions GKlibSystem.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:
Expand All @@ -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)
Expand All @@ -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.
Expand Down Expand Up @@ -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)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion win32/adapt.c → src/win32/adapt.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
\brief Implementation of Win32 adaptation of libc functions
*/

#include "adapt.h"
#include "win32/adapt.h"

pid_t getpid(void)
{
Expand Down