adds proper cmake build targets

Fri, 20 Dec 2019 14:29:41 +0100

author
Mike Becker <universe@uap-core.de>
date
Fri, 20 Dec 2019 14:29:41 +0100
changeset 375
460c0258bb5b
parent 374
be77fb2da242
child 376
028039652b86

adds proper cmake build targets

CMakeLists.txt file | annotate | diff | comparison | revisions
src/CMakeLists.txt file | annotate | diff | comparison | revisions
test/CMakeLists.txt file | annotate | diff | comparison | revisions
--- a/CMakeLists.txt	Thu Dec 19 19:58:41 2019 +0100
+++ b/CMakeLists.txt	Fri Dec 20 14:29:41 2019 +0100
@@ -1,33 +1,17 @@
 cmake_minimum_required(VERSION 3.15)
-project(ucx)
+project(ucx VERSION 2.1 DESCRIPTION "UAP Common Extensions")
 
-# Autotools Buildsystem
-add_custom_command(
-        OUTPUT ${CMAKE_SOURCE_DIR}/configure
-        MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/configure.ac
-        COMMAND ${CMAKE_SOURCE_DIR}/autogen.sh
-        COMMENT "Generating configure script.")
+# Configuration
+set(CMAKE_C_STANDARD 11)
+set(CMAKE_C_STANDARD_REQUIRED  99)
 
-add_custom_command(
-        OUTPUT ${CMAKE_SOURCE_DIR}/Makefile
-        DEPENDS ${CMAKE_SOURCE_DIR}/configure
-        COMMAND ${CMAKE_SOURCE_DIR}/configure
-        COMMENT "Configuring project.")
+# Library
+add_subdirectory(src)
 
-add_custom_target(libucx-build
-        DEPENDS ${CMAKE_SOURCE_DIR}/Makefile
-        COMMAND $(MAKE) -f ${CMAKE_SOURCE_DIR}/Makefile
-        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
-
-add_custom_target(libucx-clean
-        DEPENDS ${CMAKE_SOURCE_DIR}/Makefile
-        COMMAND $(MAKE) -f ${CMAKE_SOURCE_DIR}/Makefile clean
-        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
-
-add_custom_target(libucx-check
-        DEPENDS ${CMAKE_SOURCE_DIR}/Makefile
-        COMMAND $(MAKE) ${CMAKE_SOURCE_DIR}/Makefile check
-        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
+# Tests
+enable_testing()
+add_subdirectory(test)
+add_test(NAME test COMMAND ucxtest WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test")
 
 # Web Documentation
 add_subdirectory(docs/src)
@@ -54,5 +38,3 @@
 endif()
 
 add_custom_target(docs-all DEPENDS docs-html docs-api)
-
-add_custom_target(build-all DEPENDS docs-all libucx-check)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/CMakeLists.txt	Fri Dec 20 14:29:41 2019 +0100
@@ -0,0 +1,25 @@
+set(sources
+        allocator.c
+        array.c
+        avl.c
+        buffer.c
+        list.c
+        logging.c
+        map.c
+        mempool.c
+        properties.c
+        stack.c
+        string.c
+        test.c
+        ucx.c
+        utils.c
+)
+
+add_library(ucx SHARED ${sources})
+add_library(ucx_static STATIC ${sources})
+
+target_include_directories(ucx PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
+target_include_directories(ucx_static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
+
+set_target_properties(ucx PROPERTIES SOVERSION 3 VERSION 3.1.0)
+set_target_properties(ucx_static PROPERTIES VERSION ${CMAKE_PROJECT_VERSION})
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/CMakeLists.txt	Fri Dec 20 14:29:41 2019 +0100
@@ -0,0 +1,17 @@
+add_executable(ucxtest
+        allocator_tests.c
+        array_tests.c
+        avl_tests.c
+        buffer_tests.c
+        list_tests.c
+        logging_tests.c
+        main.c
+        map_tests.c
+        mpool_tests.c
+        prop_tests.c
+        stack_tests.c
+        string_tests.c
+        utils_tests.c
+)
+
+target_link_libraries(ucxtest PRIVATE ucx_static)

mercurial