Merge pull request #44 from eugenyk/master
authorMax Khizhinsky <libcds.dev@gmail.com>
Sun, 29 Nov 2015 20:41:07 +0000 (23:41 +0300)
committerMax Khizhinsky <libcds.dev@gmail.com>
Sun, 29 Nov 2015 20:41:07 +0000 (23:41 +0300)
CMake description and tuning

14 files changed:
.gitignore
CMakeLists.txt
build/cmake/description.txt [new file with mode: 0644]
build/cmake/post_install_script.sh [new file with mode: 0755]
build/cmake/post_uninstall_script.sh [new file with mode: 0755]
build/cmake/readme.md [new file with mode: 0644]
tests/CMakeLists.txt
tests/test-hdr/CMakeLists.txt
tests/unit/CMakeLists.txt
tests/unit/map2/CMakeLists.txt
tests/unit/pqueue/CMakeLists.txt
tests/unit/queue/CMakeLists.txt
tests/unit/set2/CMakeLists.txt
tests/unit/stack/CMakeLists.txt

index e4a293eddb30de76a3be1675797505ab12102949..d34994c1855d428ebb3326ebb6e93fc6c47a98bb 100644 (file)
@@ -17,3 +17,4 @@
 /projects/Win/vc14/.vs/
 /todo-2.1.txt
 *.log
+/.project
index 68c1e04e2779dd0591c89d9435b7ce71afe9e2a7..ba1092faaa40860edeb4e87de125d512e349ac35 100644 (file)
@@ -7,19 +7,30 @@ set(PROJECT_VERSION 2.1.0)
 
 # Options
 option(WITH_TESTS "Build unit tests" OFF)
+option(WITH_BOOST_ATOMIC "Use boost atomics (only for boost >= 1.54)" OFF)
 
 find_package(Threads REQUIRED)
-find_package(Boost COMPONENTS system thread REQUIRED)
+find_package(Boost 1.50 COMPONENTS system thread REQUIRED)
+
 include_directories(${Boost_INCLUDE_DIRS})
 
+if(WITH_BOOST_ATOMIC)
+  if(${Boost_MINOR_VERSION} GREATER 53)
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCDS_USE_BOOST_ATOMIC")
+    message(STATUS "Boost version allows using of boost.atomic: activated")
+  endif()
+endif(WITH_BOOST_ATOMIC)
+
 set(CDS_SHARED_LIBRARY ${PROJECT_NAME})
+set(CDS_STATIC_LIBRARY ${PROJECT_NAME}-s)
+
 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
 set(CMAKE_INCLUDE_CURRENT_DIR ON)
 
 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
 set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
 
-if (NOT CMAKE_BUILD_TYPE)
+if(NOT CMAKE_BUILD_TYPE)
   set(CMAKE_BUILD_TYPE Debug CACHE STRING "Default build type to Debug" FORCE)
 endif()
 
@@ -49,9 +60,12 @@ set(SOURCES src/hp_gc.cpp
             src/dllmain.cpp)
 
 add_library(${CDS_SHARED_LIBRARY} SHARED ${SOURCES})
+add_library(${CDS_STATIC_LIBRARY} STATIC ${SOURCES})
 target_link_libraries(${CDS_SHARED_LIBRARY} PRIVATE ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
+target_link_libraries(${CDS_STATIC_LIBRARY} PRIVATE ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
 
 install(TARGETS ${CDS_SHARED_LIBRARY} DESTINATION lib COMPONENT ${LIBRARIES_COMPONENT})
+install(TARGETS ${CDS_STATIC_LIBRARY} DESTINATION lib COMPONENT ${LIBRARIES_COMPONENT})
 install(DIRECTORY ${CMAKE_SOURCE_DIR}/cds DESTINATION include COMPONENT ${HEADERS_COMPONENT})
 
 if(WITH_TESTS)
@@ -59,11 +73,13 @@ if(WITH_TESTS)
   add_subdirectory(${CMAKE_SOURCE_DIR}/tests)
 endif(WITH_TESTS)
 
-### FOR PACKAGING in RPM, TGZ...###############################################################################
+### FOR PACKAGING in RPM, TGZ, DEB, NSYS...###############################################################################
 set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
 set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
+set(CPACK_PACKAGE_CONTACT "Max Khizhinsky <libcds-user@lists.sourceforge.net>")
 set(CPACK_PACKAGE_RELEASE 1)
-set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/install/description.txt")
+set(CPACK_PACKAGE_INSTALL_DIRECTORY "cds")
+set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/build/cmake/description.txt")
 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Library of concurrent data structures")
 set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}")
 set(DEPLOY_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}")
@@ -73,26 +89,36 @@ set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)
 
 # RPM specific
 set(CPACK_RPM_COMPONENT_INSTALL ON)
-set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/install/post_install_script.sh")
-set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/install/post_uninstall_script.sh")
-#set(CPACK_RPM_CHANGELOG_FILE ${CHANGELOG_INCLUDE})
+set(CPACK_RPM_PACKAGE_RELEASE ${CPACK_PACKAGE_RELEASE})
+set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/build/cmake/post_install_script.sh")
+set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/build/cmake/post_uninstall_script.sh")
+set(CPACK_RPM_PACKAGE_URL https://github.com/khizmax/libcds)
 set(CPACK_RPM_PACKAGE_LICENSE GPL)
 set(CPACK_RPM_PACKAGE_GROUP "System Environment/Base")
 set(CPACK_RPM_PACKAGE_REQUIRES "boost >= 1.50")
 set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION ${CPACK_PACKAGING_INSTALL_PREFIX})
 set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION /usr/local)
+set(CPACK_RPM_devel_PACKAGE_REQUIRES "boost >= 1.50, cds-lib = ${PROJECT_VERSION}")
 
 # DEB specific
+set(CPACK_DEB_COMPONENT_INSTALL ON)
 set(CPACK_DEBIAN_PACKAGE_DEPENDS "boost (>= 1.50)")
+set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/khizmax/libcds")
+set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_SOURCE_DIR}/build/cmake/post_install_script.sh;;${CMAKE_SOURCE_DIR}/build/cmake/post_uninstall_script.sh;" )
+
+# NSYS specific
+set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_NAME}")
+set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_NAME}")
+set(CPACK_NSIS_CONTACT ${CPACK_PACKAGE_CONTACT})
+set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
+set(CPACK_NSIS_MODIFY_PATH ON)
 
 # Components grouping for Mac OS X and Windows installers
 set(CPACK_COMPONENT_${LIBRARIES_COMPONENT}_GROUP "Runtime")
 set(CPACK_COMPONENT_${HEADERS_COMPONENT}_GROUP "Development")
 set(CPACK_COMPONENT_${LIBRARIES_COMPONENT}_DISPLAY_NAME "Libraries")
 set(CPACK_COMPONENT_${HEADERS_COMPONENT}_DISPLAY_NAME "C++ Headers")
-
 set(CPACK_COMPONENT_${HEADERS_COMPONENT}_DEPENDS ${LIBRARIES_COMPONENT})
-
 set(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION "All of the tools you'll ever need to develop lock-free oriented software with libcds")
 set(CPACK_COMPONENT_GROUP_RUNTIME_DESCRIPTION "Only libcds library for runtime")
 
diff --git a/build/cmake/description.txt b/build/cmake/description.txt
new file mode 100644 (file)
index 0000000..14beb95
--- /dev/null
@@ -0,0 +1 @@
+ПК обработки измерительной информации НАП
\ No newline at end of file
diff --git a/build/cmake/post_install_script.sh b/build/cmake/post_install_script.sh
new file mode 100755 (executable)
index 0000000..aea3041
--- /dev/null
@@ -0,0 +1 @@
+ldconfig
\ No newline at end of file
diff --git a/build/cmake/post_uninstall_script.sh b/build/cmake/post_uninstall_script.sh
new file mode 100755 (executable)
index 0000000..aea3041
--- /dev/null
@@ -0,0 +1 @@
+ldconfig
\ No newline at end of file
diff --git a/build/cmake/readme.md b/build/cmake/readme.md
new file mode 100644 (file)
index 0000000..ae2034e
--- /dev/null
@@ -0,0 +1,93 @@
+Building library with CMake
+===============
+
+CDS suports both in-source and out-of-source cmake build types. Now project uses:
+
+- CMake: general cross-platform building
+- CTest: all unit tests can be run in a standard way by *ctest* command
+- CPack: for making rpm/deb/nsys etc. packages
+
+Compiling and testing
+----------
+**Building out-of-source in "RELEASE" mode ("DEBUG" is default)**
+
+- Wherever create empty directory for building, for instance *libcds-debug*  
+- Prepare: *cmake -DCMAKE_BUILD_TYPE=RELEASE <path to the project's root directory with CMakeLists.txt>*
+- Compile: *make -j4*
+- As a result you'll see shared and static cds libraries in the build directory
+
+After using command *cmake -L <path to the project's root directory with CMakeLists.txt>* one can see some additional variables, that can activate additional features:
+
+- *WITH_TESTS:BOOL=OFF*: if you want to build library with unit testing support use *-DWITH_TESTS=ON* on prepare step. Be careful with this flag, because compile time will dramatically increase
+- *WITH_BOOST_ATOMIC:BOOL=OFF*: Use boost atomics (only for boost >= 1.54)
+- ...  
+
+Packaging
+----------
+
+In order to package library *CPack* is used, command *cpack -G <Generator>* should create correspondent packages for particular operating system. Now the project supports building the following package types:
+
+- *RPM*: redhat-based linux distribs        
+- *DEB*: debian-based linux distribs
+- *TGZ*: simple "*tgz*" archive with library and headers
+- *NSYS*: windows installer package (NSYS should be installed)   
+  
+"Live" building and packaging example
+----------
+- git clone https://github.com/khizmax/libcds.git
+- mkdir libcds-release
+- cd libcds-release
+- cmake -DWITH\_TESTS=ON -DCMAKE\_BUILD_TYPE=RELEASE ../libcds
+
+    -- The C compiler identification is GNU 4.8.3
+    -- The CXX compiler identification is GNU 4.8.3
+    ...
+    -- Found Threads: TRUE
+    -- Boost version: 1.54.0
+    -- Found the following Boost libraries:
+    --   system
+    --   thread
+    Build type -- RELEASE
+    -- Configuring done
+    -- Generating done
+    -- Build files have been written to: <...>/libcds-release
+    
+- make -j4
+  
+    Scanning dependencies of target cds
+    Scanning dependencies of target test-common
+    Scanning dependencies of target cds-s
+    Scanning dependencies of target test-hdr-offsetof
+    [  1%] Building CXX object CMakeFiles/cds-s.dir/src/hp_gc.cpp.o
+    ...
+    [100%] Built target test-hdr
+    gmake: выход из каталога «/home/kel/projects_cds/libcds-debug»
+        
+- ctest
+
+    Test project /home/kel/projects_cds/libcds-debug
+        Start 1: test-hdr
+    1/7 Test #1: test-hdr .........................   Passed  1352.24 sec
+        Start 2: cdsu-misc
+    2/7 Test #2: cdsu-misc ........................   Passed    0.00 sec
+        Start 3: cdsu-map
+    ...
+    
+- cpack -G RPM
+
+    CPack: Create package using RPM
+    CPack: Install projects
+    CPack: - Run preinstall target for: cds
+    CPack: - Install project: cds
+    CPack: -   Install component: devel
+    CPack: -   Install component: lib
+    CPack: Create package
+    CPackRPM:Debug: Adding /usr/local to builtin omit list.
+    CPackRPM: Will use GENERATED spec file: /home/kel/projects_cds/libcds-debug/_CPack_Packages/Linux/RPM/SPECS/cds-devel.spec
+    CPackRPM: Will use GENERATED spec file: /home/kel/projects_cds/libcds-debug/_CPack_Packages/Linux/RPM/SPECS/cds-lib.spec
+    CPack: - package: /home/kel/projects_cds/libcds-debug/cds-2.1.0-1-devel.rpm generated.
+    CPack: - package: /home/kel/projects_cds/libcds-debug/cds-2.1.0-1-lib.rpm generated.
+  
+Future development
+----------
+- CDash: use CI system
\ No newline at end of file
index edec379078e7d63598b2912b8410aefb300f99cb..3de95852f47c997a3d398141975d5bd642fbb780 100644 (file)
@@ -13,5 +13,5 @@ add_library(${TEST_COMMON} OBJECT ${SOURCES})
 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test-hdr)
 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/unit)
 
-file(GLOB  CONF_FILES data/*.conf)
+file(GLOB CONF_FILES ${PROJECT_SOURCE_DIR}/tests/data/*.conf)
 file(COPY ${CONF_FILES} DESTINATION ${EXECUTABLE_OUTPUT_PATH})
\ No newline at end of file
index c93157a1de5aaeb4789e846aa2ad2c04005100aa..7e41be48c79b06bafc2e9c5e58d5eaf475504328 100644 (file)
@@ -414,4 +414,4 @@ set(CDS_TESTHDR_SOURCES
 \r
 add_executable(${PACKAGE_NAME} ${CDS_TESTHDR_SOURCES} $<TARGET_OBJECTS:test-hdr-offsetof> $<TARGET_OBJECTS:${TEST_COMMON}>)\r
 target_link_libraries(${PACKAGE_NAME} ${CDS_SHARED_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})\r
-add_test(NAME ${PACKAGE_NAME} COMMAND ${PACKAGE_NAME})
\ No newline at end of file
+add_test(NAME ${PACKAGE_NAME} COMMAND ${PACKAGE_NAME} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
\ No newline at end of file
index ffd672dd5925947d62491fb30a7e0815c0f0d2dd..1d3063c733908443dbba34a0e584f162d17f0a78 100644 (file)
@@ -12,7 +12,7 @@ set(CDSUNIT_MISC_SOURCES
 
 add_executable(${PACKAGE_NAME} ${CDSUNIT_MAP_SOURCES} $<TARGET_OBJECTS:${TEST_COMMON}>)
 target_link_libraries(${PACKAGE_NAME} ${CDS_SHARED_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
-add_test(NAME ${PACKAGE_NAME} COMMAND ${PACKAGE_NAME})
+add_test(NAME ${PACKAGE_NAME} COMMAND ${PACKAGE_NAME} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
 
 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/map2)
 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/pqueue)
index dc30aa0e5c6cf9885264350aad97e3c8bd385dba..1a55ab844fc0c06ecb52cb6c05f02f51364d1b99 100644 (file)
@@ -25,8 +25,8 @@ set(CDSUNIT_MAP_SOURCES
     map_insfind_int_bronsonavltree.cpp
     map_insfind_int_cuckoo.cpp
     map_insfind_int_ellentree.cpp
+    map_insfind_int_feldmanhashmap.cpp
     map_insfind_int_michael.cpp
-    map_insfind_int_multievelhashmap.cpp
     map_insfind_int_skip.cpp
     map_insfind_int_split.cpp
     map_insfind_int_striped.cpp
@@ -100,4 +100,4 @@ set(CDSUNIT_MAP_SOURCES
 
 add_executable(${PACKAGE_NAME} ${CDSUNIT_MAP_SOURCES} $<TARGET_OBJECTS:${TEST_COMMON}>)
 target_link_libraries(${PACKAGE_NAME} ${CDS_SHARED_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
-add_test(NAME ${PACKAGE_NAME} COMMAND ${PACKAGE_NAME})
\ No newline at end of file
+add_test(NAME ${PACKAGE_NAME} COMMAND ${PACKAGE_NAME} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
\ No newline at end of file
index d89a966a6199320b27536f72b8243d0ef70da0a2..ae2a6d8b82f39ac27d3d24afdb6087f333ac227d 100644 (file)
@@ -7,4 +7,4 @@ set(CDSUNIT_PQUEUE_SOURCES
 
 add_executable(${PACKAGE_NAME} ${CDSUNIT_PQUEUE_SOURCES} $<TARGET_OBJECTS:${TEST_COMMON}>)
 target_link_libraries(${PACKAGE_NAME} ${CDS_SHARED_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
-add_test(NAME ${PACKAGE_NAME} COMMAND ${PACKAGE_NAME})
\ No newline at end of file
+add_test(NAME ${PACKAGE_NAME} COMMAND ${PACKAGE_NAME} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
\ No newline at end of file
index b32e7123fc7d743405e0b3132728b8e92cb78bf8..f41f29cf3463c81c2e3e09933e2b7f4a09ffc561 100644 (file)
@@ -10,4 +10,4 @@ set(CDSUNIT_QUEUE_SOURCES
 
 add_executable(${PACKAGE_NAME} ${CDSUNIT_QUEUE_SOURCES} $<TARGET_OBJECTS:${TEST_COMMON}>)
 target_link_libraries(${PACKAGE_NAME} ${CDS_SHARED_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
-add_test(NAME ${PACKAGE_NAME} COMMAND ${PACKAGE_NAME})
\ No newline at end of file
+add_test(NAME ${PACKAGE_NAME} COMMAND ${PACKAGE_NAME} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
\ No newline at end of file
index 89e71cf1352fc6f532aa9bc51f5b5d73a2530e39..4431cdd3b6b1b5edf7f8fcfc8d6f9522686aec1a 100644 (file)
@@ -38,4 +38,4 @@ set(CDSUNIT_SET_SOURCES
 
 add_executable(${PACKAGE_NAME} ${CDSUNIT_SET_SOURCES} $<TARGET_OBJECTS:${TEST_COMMON}>)
 target_link_libraries(${PACKAGE_NAME} ${CDS_SHARED_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
-add_test(NAME ${PACKAGE_NAME} COMMAND ${PACKAGE_NAME})
\ No newline at end of file
+add_test(NAME ${PACKAGE_NAME} COMMAND ${PACKAGE_NAME} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
\ No newline at end of file
index f521144c614330c264d963339178da1dd9fa957a..ea341729682153b1004c8f1b882da2c096df83b3 100644 (file)
@@ -7,4 +7,4 @@ set(CDSUNIT_STACK_SOURCES
 
 add_executable(${PACKAGE_NAME} ${CDSUNIT_STACK_SOURCES} $<TARGET_OBJECTS:${TEST_COMMON}>)
 target_link_libraries(${PACKAGE_NAME} ${CDS_SHARED_LIBRARY} ${Boost_THREAD_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
-add_test(NAME ${PACKAGE_NAME} COMMAND ${PACKAGE_NAME})
\ No newline at end of file
+add_test(NAME ${PACKAGE_NAME} COMMAND ${PACKAGE_NAME} WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
\ No newline at end of file