Initial conversion to CMake
This commit is contained in:
@@ -0,0 +1,42 @@
|
|||||||
|
project(libucore C)
|
||||||
|
cmake_minimum_required(VERSION 3.0.0)
|
||||||
|
|
||||||
|
execute_process(COMMAND git -C ${CMAKE_SOURCE_DIR} describe --abbrev=5 --dirty --always OUTPUT_VARIABLE version_revision WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
execute_process(COMMAND hostname OUTPUT_VARIABLE build_host OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
|
||||||
|
set(libucore_VERSION_MAJOR 1)
|
||||||
|
set(libucore_VERSION_MINOR 0)
|
||||||
|
set(libucore_VERSION_PATCH 0)
|
||||||
|
set(libucore_VERSION ${libucore_VERSION_MAJOR}.${libucore_VERSION_MINOR}.${libucore_VERSION_PATCH}.${version_revision})
|
||||||
|
|
||||||
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||||
|
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -pthread")
|
||||||
|
|
||||||
|
|
||||||
|
option(CODE_COVERAGE "build with code coverage intrumentation" OFF)
|
||||||
|
if (CODE_COVERAGE)
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
|
||||||
|
add_definitions(-DCOVERAGE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option(BUILD_DEBUG "build debug binaries" ON)
|
||||||
|
if (BUILD_ENVOY_DEBUG)
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
|
||||||
|
add_definitions(-DDEBUG)
|
||||||
|
else()
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
|
||||||
|
add_definitions(-DNDEBUG)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option(BUILD_SANITIZE "build with address sanitizer" OFF)
|
||||||
|
if (BUILD_SANITIZE)
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include_directories(include)
|
||||||
|
|
||||||
|
add_subdirectory(src)
|
||||||
|
add_subdirectory(test)
|
||||||
|
add_subdirectory(include)
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
install(DIRECTORY ucore DESTINATION include)
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
configure_file (
|
||||||
|
"version.c.in"
|
||||||
|
"version.c"
|
||||||
|
)
|
||||||
|
file(GLOB SOURCE_FILES *.c)
|
||||||
|
|
||||||
|
add_library(
|
||||||
|
ucore SHARED
|
||||||
|
${SOURCE_FILES}
|
||||||
|
"${PROJECT_BINARY_DIR}/src/version.c"
|
||||||
|
)
|
||||||
|
set_target_properties(ucore PROPERTIES SOVERSION 1 VERSION 1.0.0)
|
||||||
|
target_link_libraries(ucore pthread)
|
||||||
|
install (TARGETS ucore DESTINATION lib)
|
||||||
+4
-4
@@ -1,11 +1,11 @@
|
|||||||
//Various info about the version and build.
|
//Various info about the version and build.
|
||||||
//The SConscript file substitutes these at build time
|
//The SConscript file substitutes these at build time
|
||||||
|
|
||||||
const int ucore_version_major = @version_major@;
|
const int ucore_version_major = @libucore_VERSION_MAJOR@;
|
||||||
const int ucore_version_minor = @version_minor@;
|
const int ucore_version_minor = @libucore_VERSION_MINOR@;
|
||||||
const int ucore_version_patch = @version_patch@;
|
const int ucore_version_patch = @libucore_VERSION_PATCH@;
|
||||||
|
|
||||||
const char ucore_version_str[] = "@version_str@";
|
const char ucore_version_str[] = "@libucore_VERSION@";
|
||||||
const char ucore_build_host[] = "@build_host@";
|
const char ucore_build_host[] = "@build_host@";
|
||||||
const char ucore_build_type[] = "@build_type@";
|
const char ucore_build_type[] = "@build_type@";
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
file(GLOB TEST_SOURCE_FILES test_*.c)
|
||||||
|
|
||||||
|
add_executable(test_runner ${TEST_SOURCE_FILES})
|
||||||
|
target_link_libraries(test_runner check ucore rt)
|
||||||
|
|
||||||
|
add_custom_target(runtest COMMAND test_runner
|
||||||
|
DEPENDS test_runner
|
||||||
|
WORKING_DIRECTORY ${CMAKE_PROJECT_DIR})
|
||||||
Reference in New Issue
Block a user