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
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ option(WITH_PACKAGING "Enable packaging" ON)
# Must include cotire before anything else for auto pch setup
#include(cmake/cotire.cmake)

# Load our common utility api and setup the platfomrm and build
include(cmake/ksutil.cmake)
ksutil_setup_platform()

# Find stuff we need for packaging on UNIX
if(KS_PLAT_LIN AND WITH_PACKAGING)
find_package(Git)
Expand Down Expand Up @@ -46,6 +42,10 @@ endif()
project(LibKS2 VERSION 2.0.8 LANGUAGES C CXX)
message("LibKS2 Version ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")

# Load our common utility api and setup the platfomrm and build
include(cmake/ksutil.cmake)
ksutil_setup_platform()

# Set package version
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
Expand Down
24 changes: 24 additions & 0 deletions cmake/ksutil.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,30 @@ macro(ksutil_setup_platform)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
elseif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
message("Platform is FreeBSD")
set(KS_PLAT_FBSD 1 CACHE INTERNAL "Platform definition" FORCE)
set(CMAKE_POSITION_INDEPENDENT_CODE YES)

add_compile_options("$<$<CONFIG:Release>:-O2>")
add_compile_options("$<$<CONFIG:Release>:-g>")

add_compile_options("$<$<CONFIG:Debug>:-O0>")
add_compile_options("$<$<CONFIG:Debug>:-g>")
add_compile_options("$<$<CONFIG:Debug>:-DKS_BUILD_DEBUG=1>")

add_compile_options("$<$<CONFIG:Sanitize>:-O0>")
add_compile_options("$<$<CONFIG:Sanitize>:-g>")
add_compile_options("$<$<CONFIG:Sanitize>:-fsanitize=address>")
add_compile_options("$<$<CONFIG:Sanitize>:-DKS_BUILD_DEBUG=1>")

add_definitions("-DKS_PLAT_BSD=1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")

if (NOT CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE INTERNAL "Prefix prepended to install directories" FORCE)
set(CMAKE_PREFIX_PATH "/usr/local" CACHE INTERNAL "Prefix search path" FORCE)
endif()
else()
message("Platform is linux")
set(KS_PLAT_LIN 1 CACHE INTERNAL "Platform definition" FORCE)
Expand Down
6 changes: 5 additions & 1 deletion src/include/libks/ks_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

KS_BEGIN_EXTERN_C

#if !defined(KS_PLAT_LIN) && !defined(KS_PLAT_WIN) && !defined(KS_PLAT_MAC)
#if !defined(KS_PLAT_LIN) && !defined(KS_PLAT_WIN) && !defined(KS_PLAT_MAC) && !defined(KS_PLAT_FBSD)
#ifdef __linux__
#define KS_PLAT_LIN
#else
Expand All @@ -34,6 +34,10 @@ KS_BEGIN_EXTERN_C
#else
#ifdef __APPLE__
#define KS_PLAT_MAC
#else
#ifdef __FreeBSD__
#define KS_PLAT_FBSD
#endif
#endif
#endif
#endif
Expand Down
4 changes: 4 additions & 0 deletions src/include/libks/ks_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@ KS_BEGIN_EXTERN_C
#include <Rpc.h>
typedef UUID ks_uuid_t;
#else
#ifdef KS_PLAT_FBSD
#include <uuid.h>
#else
#include <uuid/uuid.h>
#endif

/* Use a structure rather then uuids char array, that way
* we can return it by value*/
Expand Down
6 changes: 6 additions & 0 deletions src/ks_json_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@
*
*/
#include "libks/ks.h"

#ifndef KS_PLAT_WIN
#ifdef KS_PLAT_FBSD
#include <uuid.h>
#else
#include <uuid/uuid.h>
#endif
#endif
#include "cJSON/cJSON.h"


/* todo move util functions to ks_utils.c */

/*!
Expand Down
2 changes: 2 additions & 0 deletions src/ks_thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ KS_DECLARE(ks_pid_t) ks_thread_self_id(void)
return GetCurrentThreadId();
#elif defined(KS_PLAT_LIN)
return syscall(SYS_gettid);
#elif defined(KS_PLAT_FBSD)
return pthread_getthreadid_np();
#elif defined(KS_PLAT_MAC)
uint64_t tid;
int r = pthread_threadid_np(NULL, &tid);
Expand Down