Merge branch 'dev'
[libcds.git] / build / cmake / readme.md
1 Building library with CMake
2 ===============
3
4 CDS suports both in-source and out-of-source cmake build types. Now project uses:
5
6 - CMake: general cross-platform building
7 - CTest: all unit tests can be run in a standard way by *ctest* command
8 - CPack: for making rpm/deb/nsys etc. packages
9
10 Compiling and testing
11 ----------
12 **Building out-of-source in "RELEASE" mode ("DEBUG" is default)**
13
14 - Wherever create empty directory for building, for instance *libcds-debug*  
15 - Prepare: *cmake -DCMAKE_BUILD_TYPE=RELEASE <path to the project's root directory with CMakeLists.txt>*
16 - Compile: *make -j4*
17 - As a result you'll see shared and static cds libraries in the build directory
18
19 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:
20
21 - *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
22 - *WITH_TESTS_COVERAGE:BOOL=OFF*: Analyze test coverage using gcov (only for gcc)
23 - *WITH_BOOST_ATOMIC:BOOL=OFF*: Use boost atomics (only for boost >= 1.54)
24 - ...  
25
26 Packaging
27 ----------
28
29 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:
30
31 - *RPM*: redhat-based linux distribs        
32 - *DEB*: debian-based linux distribs
33 - *TGZ*: simple "*tgz*" archive with library and headers
34 - *NSYS*: windows installer package (NSYS should be installed)   
35   
36 "Live" building and packaging example
37 ----------
38 - git clone https://github.com/khizmax/libcds.git
39 - mkdir libcds-release
40 - cd libcds-release
41 - cmake -DWITH\_TESTS=ON -DCMAKE\_BUILD_TYPE=RELEASE ../libcds
42 ```
43     -- The C compiler identification is GNU 4.8.3
44     -- The CXX compiler identification is GNU 4.8.3
45     ...
46     -- Found Threads: TRUE
47     -- Boost version: 1.54.0
48     -- Found the following Boost libraries:
49     --   system
50     --   thread
51     Build type -- RELEASE
52     -- Configuring done
53     -- Generating done
54     -- Build files have been written to: <...>/libcds-release
55 ``` 
56 - make -j4
57 ```
58     Scanning dependencies of target cds
59     Scanning dependencies of target test-common
60     Scanning dependencies of target cds-s
61     Scanning dependencies of target test-hdr-offsetof
62     [  1%] Building CXX object CMakeFiles/cds-s.dir/src/hp_gc.cpp.o
63     ...
64     [100%] Built target test-hdr
65     gmake: выход из каталога «/home/kel/projects_cds/libcds-debug»
66 ```
67
68 - ctest
69 ```
70     Test project /home/kel/projects_cds/libcds-debug
71         Start 1: test-hdr
72     1/7 Test #1: test-hdr .........................   Passed  1352.24 sec
73         Start 2: cdsu-misc
74     2/7 Test #2: cdsu-misc ........................   Passed    0.00 sec
75         Start 3: cdsu-map
76     ...
77 ```
78
79 - cpack -G RPM
80 ```
81     CPack: Create package using RPM
82     CPack: Install projects
83     CPack: - Run preinstall target for: cds
84     CPack: - Install project: cds
85     CPack: -   Install component: devel
86     CPack: -   Install component: lib
87     CPack: Create package
88     CPackRPM:Debug: Adding /usr/local to builtin omit list.
89     CPackRPM: Will use GENERATED spec file: /home/kel/projects_cds/libcds-debug/_CPack_Packages/Linux/RPM/SPECS/cds-devel.spec
90     CPackRPM: Will use GENERATED spec file: /home/kel/projects_cds/libcds-debug/_CPack_Packages/Linux/RPM/SPECS/cds-lib.spec
91     CPack: - package: /home/kel/projects_cds/libcds-debug/cds-2.1.0-1-devel.rpm generated.
92     CPack: - package: /home/kel/projects_cds/libcds-debug/cds-2.1.0-1-lib.rpm generated.
93 ```
94
95 Future development
96 ----------
97 - CDash: use CI system