Skip to content

Commit

Permalink
cmake support
Browse files Browse the repository at this point in the history
* add version.h
* bump version
  • Loading branch information
recp committed May 19, 2020
1 parent 64ae6c5 commit 19f6c7f
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@ test-driver
*.gcda
tests.trs
tests

build/
78 changes: 78 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
cmake_minimum_required(VERSION 3.8.2)
project(ds VERSION 0.2.2 LANGUAGES C)

set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED YES)
set(DEFAULT_BUILD_TYPE "Release")

set(DS_BUILD)
option(DS_SHARED "Shared build" ON)
option(DS_STATIC "Static build" OFF)
option(DS_USE_C99 "" OFF)
option(DS_USE_TEST "Enable Tests" OFF)

if(NOT DS_STATIC AND DS_SHARED)
set(DS_BUILD SHARED)
else(DS_STATIC)
set(DS_BUILD STATIC)
endif()

if(DS_USE_C99)
set(C_STANDARD 99)
endif()

if(MSVC)
add_definitions(-DNDEBUG -D_WINDOWS -D_USRDLL -DDS_EXPORTS -DDS_DLL)
add_compile_options(/W3 /Ox /Gy /Oi /TC)
else()
add_compile_options(-Wall -Werror -O3)
endif()

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

include(GNUInstallDirs)

set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)

# Target Start
add_library(${PROJECT_NAME}
${DS_BUILD}
src/default/default.c
src/allocator.c
src/util.c
src/rb.c
src/forward_list.c
src/flist_separate.c
src/hash_table.c
src/hash_funcs.c
src/sort/sort.c
)

set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR})

target_include_directories(${PROJECT_NAME} PRIVATE include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)

# Install
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})

install(DIRECTORY include/${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
PATTERN ".*" EXCLUDE)

# Test Configuration
if(DS_USE_TEST)
include(CTest)
enable_testing()
add_subdirectory(test)
endif()
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#*****************************************************************************

AC_PREREQ([2.69])
AC_INIT([ds], [0.2.1], [[email protected]])
AC_INIT([ds], [0.2.2], [[email protected]])
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects serial-tests])

AC_CONFIG_MACRO_DIR([m4])
Expand Down
3 changes: 2 additions & 1 deletion makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ test_tests_LDFLAGS = $(checkLDFLAGS)
test_tests_CFLAGS = $(checkCFLAGS)

dsdir=$(includedir)/ds
ds_HEADERS = include/ds/rb.h \
ds_HEADERS = include/ds/version.h \
include/ds/rb.h \
include/ds/util.h \
include/ds/common.h \
include/ds/allocator.h \
Expand Down

0 comments on commit 19f6c7f

Please sign in to comment.