aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2018-09-27 12:36:54 +0300
committergramanas <anastasis.gramm2@gmail.com>2018-09-27 12:36:54 +0300
commit03917439a1ddcf202e9fc53937b10eeb7ec0a99a (patch)
treed45b75be65d08be774058d67fda94bc7665bdce9
parent7286c9fc5b55df0499c7a8f28b5e61ec57e788cc (diff)
downloadck-03917439a1ddcf202e9fc53937b10eeb7ec0a99a.tar.gz
ck-03917439a1ddcf202e9fc53937b10eeb7ec0a99a.tar.bz2
ck-03917439a1ddcf202e9fc53937b10eeb7ec0a99a.zip
Update CMakeLists and build istructions
-rw-r--r--CMakeLists.txt53
-rw-r--r--README.html179
-rw-r--r--README.org62
3 files changed, 170 insertions, 124 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ff55a80..1228e82 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,21 +14,20 @@ project(ck C)
set(ck_MAJOR_VERSION 0)
set(ck_MINOR_VERSION 4)
-# compiler
-set(CMAKE_C_COMPILER clang)
-
-# compiler flags
-
# options
option(CK_ASAN "Build with asan")
-option(CK_RELEASE "Release build")
+option(CK_DEBUG "Build with debug symbols")
+option(CK_TESTS "Make the tests")
+option(CK_SHARED "Build with shared lib")
if(CK_ASAN)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address")
endif()
-if (NOT CK_RELEASE)
+if (CK_DEBUG)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3")
+else(CK_DEBUG)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
endif()
# Set project directories
@@ -79,26 +78,36 @@ include_directories(${PROJECT_BINARY_DIR})
include_directories(${CMAKE_BINARY_DIR})
include_directories(${SQLITE3_INCLUDE_DIRS})
-# Create the shared library
-add_library (ckLib SHARED
+# Create the library (static by default)
+if (CK_SHARED)
+ add_library (ckLib SHARED
+ ${ckLib_src}
+ ${ckLib_hdr}
+ )
+else(CK_SHARED)
+ add_library (ckLib STATIC
${ckLib_src}
${ckLib_hdr}
-)
+ )
+endif()
# Link
add_executable(ck ${ckBin_src})
target_link_libraries(ck ckLib)
target_link_libraries(ck ${SQLITE3_LIBRARIES})
-## unit test
-add_executable(ck-test ${ckUnitTest_src})
-target_link_libraries(ck-test ckLib)
-target_link_libraries(ck-test ${SQLITE3_LIBRARIES})
-# copy test files
-set(BIN_TESTS_DIR ${CMAKE_BINARY_DIR}/res/tests)
-set(PROJECT_TESTING_GROUNDS ${CMAKE_BINARY_DIR}/test_files)
-configure_file(${TESTS_DIR}/init ${BIN_TESTS_DIR}/init @ONLY)
-configure_file(${TESTS_DIR}/add ${BIN_TESTS_DIR}/add @ONLY)
-configure_file(${TESTS_DIR}/list ${BIN_TESTS_DIR}/list @ONLY)
-# check_ck
-configure_file(${RES_DIR}/check_ck check_ck @ONLY)
+if (CK_TESTS)
+ ## unit test
+ add_executable(ck-test ${ckUnitTest_src})
+ target_link_libraries(ck-test ckLib)
+ target_link_libraries(ck-test ${SQLITE3_LIBRARIES})
+
+ # copy test files
+ set(BIN_TESTS_DIR ${CMAKE_BINARY_DIR}/res/tests)
+ set(PROJECT_TESTING_GROUNDS ${CMAKE_BINARY_DIR}/test_files)
+ configure_file(${TESTS_DIR}/init ${BIN_TESTS_DIR}/init @ONLY)
+ configure_file(${TESTS_DIR}/add ${BIN_TESTS_DIR}/add @ONLY)
+ configure_file(${TESTS_DIR}/list ${BIN_TESTS_DIR}/list @ONLY)
+ # check_ck
+ configure_file(${RES_DIR}/check_ck check_ck @ONLY)
+endif()
diff --git a/README.html b/README.html
index 622fe6f..7a0e391 100644
--- a/README.html
+++ b/README.html
@@ -3,7 +3,7 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
-<!-- 2018-09-26 Wed 12:17 -->
+<!-- 2018-09-27 Thu 12:36 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>&lrm;</title>
@@ -232,35 +232,35 @@ for the JavaScript code in this tag.
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
-<li><a href="#orgd67b965">ck</a></li>
-<li><a href="#org3c99267">build it</a>
+<li><a href="#org0436b21">ck</a></li>
+<li><a href="#org521e187">build it</a>
<ul>
-<li><a href="#org43293eb">requirements</a></li>
-<li><a href="#orgdc47889">compiler</a></li>
-<li><a href="#orgfa2726d">make</a></li>
+<li><a href="#orgca52abe">requirements</a></li>
+<li><a href="#org6b9a0b5">compiler</a></li>
+<li><a href="#orgdbbfa92">make</a></li>
</ul>
</li>
-<li><a href="#org6d8a878">for devs</a>
+<li><a href="#orgde3e768">for devs</a>
<ul>
-<li><a href="#org7c536be">make</a></li>
-<li><a href="#org795f8ab">tests</a>
+<li><a href="#orgfaa2574">CMake options</a></li>
+<li><a href="#orgf23c175">tests</a>
<ul>
-<li><a href="#org5d71273">run tests</a></li>
-<li><a href="#orgc90fd7b">test suite</a></li>
+<li><a href="#org3dfeb24">run tests</a></li>
+<li><a href="#org9d9b2b2">test suite</a></li>
</ul>
</li>
</ul>
</li>
-<li><a href="#orgd7c063c">manual</a>
+<li><a href="#org02afa67">manual</a>
<ul>
-<li><a href="#orge585d76">ck configuration</a></li>
-<li><a href="#org2ae92a5">Actions</a>
+<li><a href="#orga3cd4d1">ck configuration</a></li>
+<li><a href="#orgacbdbc9">Actions</a>
<ul>
-<li><a href="#orgd17e778">init</a></li>
-<li><a href="#org331f5d4">add</a></li>
-<li><a href="#org2e62903">list</a></li>
-<li><a href="#org2237d57">search</a></li>
-<li><a href="#orgbced512">edit</a></li>
+<li><a href="#org0e7f64a">init</a></li>
+<li><a href="#orgb4b8714">add</a></li>
+<li><a href="#org6456e5e">list</a></li>
+<li><a href="#orgd015339">search</a></li>
+<li><a href="#orgbbfaad1">edit</a></li>
</ul>
</li>
</ul>
@@ -269,22 +269,22 @@ for the JavaScript code in this tag.
</div>
</div>
<p align="center"><img src="res/logo.png" width="30%" height="30%" /></p>
-<div id="outline-container-orgd67b965" class="outline-2">
-<h2 id="orgd67b965">ck</h2>
-<div class="outline-text-2" id="text-orgd67b965">
+<div id="outline-container-org0436b21" class="outline-2">
+<h2 id="org0436b21">ck</h2>
+<div class="outline-text-2" id="text-org0436b21">
<p>
<b>The Config Keeper</b>
</p>
</div>
</div>
-<div id="outline-container-org3c99267" class="outline-2">
-<h2 id="org3c99267">build it</h2>
-<div class="outline-text-2" id="text-org3c99267">
+<div id="outline-container-org521e187" class="outline-2">
+<h2 id="org521e187">build it</h2>
+<div class="outline-text-2" id="text-org521e187">
</div>
-<div id="outline-container-org43293eb" class="outline-3">
-<h3 id="org43293eb">requirements</h3>
-<div class="outline-text-3" id="text-org43293eb">
+<div id="outline-container-orgca52abe" class="outline-3">
+<h3 id="orgca52abe">requirements</h3>
+<div class="outline-text-3" id="text-orgca52abe">
<ul class="org-ul">
<li>clang (llvm) or gcc (gnu)</li>
<li>cmake</li>
@@ -293,19 +293,21 @@ for the JavaScript code in this tag.
</div>
</div>
-<div id="outline-container-orgdc47889" class="outline-3">
-<h3 id="orgdc47889">compiler</h3>
-<div class="outline-text-3" id="text-orgdc47889">
-<p>
-By default I use clang, if you want to use gcc just
-edit the <code>CMakeLists.txt</code> file and change <code>clang</code> to <code>gcc</code>
-</p>
+<div id="outline-container-org6b9a0b5" class="outline-3">
+<h3 id="org6b9a0b5">compiler</h3>
+<div class="outline-text-3" id="text-org6b9a0b5">
+<div class="org-src-container">
+<pre class="src src-sh">&gt; export <span style="color: #baba36;">CC</span>=clang
+<span style="color: #656565;"># </span><span style="color: #757575;">or</span>
+&gt; export <span style="color: #baba36;">CC</span>=gcc
+</pre>
+</div>
</div>
</div>
-<div id="outline-container-orgfa2726d" class="outline-3">
-<h3 id="orgfa2726d">make</h3>
-<div class="outline-text-3" id="text-orgfa2726d">
+<div id="outline-container-orgdbbfa92" class="outline-3">
+<h3 id="orgdbbfa92">make</h3>
+<div class="outline-text-3" id="text-orgdbbfa92">
<div class="org-src-container">
<pre class="src src-sh"><span style="color: #656565;"># </span><span style="color: #757575;">clone the repo</span>
&gt; cd ~/code; git clone https://gitlab.com/grm-grm/ck
@@ -323,13 +325,32 @@ edit the <code>CMakeLists.txt</code> file and change <code>clang</code> to <code
</div>
</div>
-<div id="outline-container-org6d8a878" class="outline-2">
-<h2 id="org6d8a878">for devs</h2>
-<div class="outline-text-2" id="text-org6d8a878">
+<div id="outline-container-orgde3e768" class="outline-2">
+<h2 id="orgde3e768">for devs</h2>
+<div class="outline-text-2" id="text-orgde3e768">
</div>
-<div id="outline-container-org7c536be" class="outline-3">
-<h3 id="org7c536be">make</h3>
-<div class="outline-text-3" id="text-org7c536be">
+<div id="outline-container-orgfaa2574" class="outline-3">
+<h3 id="orgfaa2574">CMake options</h3>
+<div class="outline-text-3" id="text-orgfaa2574">
+<p>
+cmake accepts the following options:
+</p>
+<div class="org-src-container">
+<pre class="src src-cmake"><span style="color: #6aaf50;">option</span>(CK_ASAN <span style="color: #bdbc61;">"Build with asan"</span>)
+<span style="color: #6aaf50;">option</span>(CK_DEBUG <span style="color: #bdbc61;">"Build with debug symbols"</span>)
+<span style="color: #6aaf50;">option</span>(CK_TESTS <span style="color: #bdbc61;">"Make the tests"</span>)
+<span style="color: #6aaf50;">option</span>(CK_SHARED <span style="color: #bdbc61;">"Build with shared lib"</span>)
+</pre>
+</div>
+
+<p>
+To use any one of them append it after the cmake command like so:
+</p>
+<div class="org-src-container">
+<pre class="src src-sh">cmake -DCK_ASAN=1 -DCK_DEBUG=1 -DCK_TESTS=1 ~/code/ck
+</pre>
+</div>
+
<p>
Just build with address sanitizer enabled like so:
llvm has better asan than gcc, so I use that.
@@ -340,7 +361,7 @@ llvm has better asan than gcc, so I use that.
<span style="color: #656565;"># </span><span style="color: #757575;">make a build directory and enter it</span>
&gt; mkdir ~/ck_build; <span style="color: #528fd1;">cd</span> ~/ck_build;
<span style="color: #656565;"># </span><span style="color: #757575;">run cmake</span>
-&gt; cmake ~/code/ck -DCK_ASAN=ON
+&gt; cmake -DCK_ASAN=1 -DCK_DEBUG=1 -DCK_TESTS=1 ~/code/ck
<span style="color: #656565;"># </span><span style="color: #757575;">run make</span>
&gt; make
<span style="color: #656565;"># </span><span style="color: #757575;">run ck</span>
@@ -350,9 +371,9 @@ llvm has better asan than gcc, so I use that.
</div>
</div>
-<div id="outline-container-org795f8ab" class="outline-3">
-<h3 id="org795f8ab">tests</h3>
-<div class="outline-text-3" id="text-org795f8ab">
+<div id="outline-container-orgf23c175" class="outline-3">
+<h3 id="orgf23c175">tests</h3>
+<div class="outline-text-3" id="text-orgf23c175">
<p>
The testing "suite" is a bash script that runs regression
and unit tests. Regression tests are under the <code>tests/</code> directory
@@ -361,9 +382,9 @@ under <code>unit/</code> directory and test the code.
</p>
</div>
-<div id="outline-container-org5d71273" class="outline-4">
-<h4 id="org5d71273">run tests</h4>
-<div class="outline-text-4" id="text-org5d71273">
+<div id="outline-container-org3dfeb24" class="outline-4">
+<h4 id="org3dfeb24">run tests</h4>
+<div class="outline-text-4" id="text-org3dfeb24">
<p>
Simply go to the build dir and type.
</p>
@@ -374,9 +395,9 @@ Simply go to the build dir and type.
</div>
</div>
-<div id="outline-container-orgc90fd7b" class="outline-4">
-<h4 id="orgc90fd7b">test suite</h4>
-<div class="outline-text-4" id="text-orgc90fd7b">
+<div id="outline-container-org9d9b2b2" class="outline-4">
+<h4 id="org9d9b2b2">test suite</h4>
+<div class="outline-text-4" id="text-org9d9b2b2">
<div class="org-src-container">
<pre class="src src-sh">$ ./check_ck -h
ck test suite
@@ -394,9 +415,9 @@ flags:
</div>
</div>
</div>
-<div id="outline-container-orgd7c063c" class="outline-2">
-<h2 id="orgd7c063c">manual</h2>
-<div class="outline-text-2" id="text-orgd7c063c">
+<div id="outline-container-org02afa67" class="outline-2">
+<h2 id="org02afa67">manual</h2>
+<div class="outline-text-2" id="text-org02afa67">
<p>
ck's goal is to assist with the configuration file management.
To that end it tries to provides a cli interface that is pretty straight-forward
@@ -446,9 +467,9 @@ of flags one has to pass to ck.
</p>
</div>
-<div id="outline-container-orge585d76" class="outline-3">
-<h3 id="orge585d76">ck configuration</h3>
-<div class="outline-text-3" id="text-orge585d76">
+<div id="outline-container-orga3cd4d1" class="outline-3">
+<h3 id="orga3cd4d1">ck configuration</h3>
+<div class="outline-text-3" id="text-orga3cd4d1">
<p>
ck uses sqlite to index the configuration files. The init
action creates a <b>.ck</b> directory (under $HOME)
@@ -490,13 +511,13 @@ $ ck -c /someplace/else ...
</div>
</div>
-<div id="outline-container-org2ae92a5" class="outline-3">
-<h3 id="org2ae92a5">Actions</h3>
-<div class="outline-text-3" id="text-org2ae92a5">
+<div id="outline-container-orgacbdbc9" class="outline-3">
+<h3 id="orgacbdbc9">Actions</h3>
+<div class="outline-text-3" id="text-orgacbdbc9">
</div>
-<div id="outline-container-orgd17e778" class="outline-4">
-<h4 id="orgd17e778">init</h4>
-<div class="outline-text-4" id="text-orgd17e778">
+<div id="outline-container-org0e7f64a" class="outline-4">
+<h4 id="org0e7f64a">init</h4>
+<div class="outline-text-4" id="text-org0e7f64a">
<p>
or i or -i
</p>
@@ -526,9 +547,9 @@ $ ck init /path_to/where_you_want/your_configs/to_be <span style="color: #bdbc61
</div>
</div>
-<div id="outline-container-org331f5d4" class="outline-4">
-<h4 id="org331f5d4">add</h4>
-<div class="outline-text-4" id="text-org331f5d4">
+<div id="outline-container-orgb4b8714" class="outline-4">
+<h4 id="orgb4b8714">add</h4>
+<div class="outline-text-4" id="text-orgb4b8714">
<p>
or a or -a
</p>
@@ -569,9 +590,9 @@ $ ck add program_name config_path [-s] [-p]
</div>
</div>
-<div id="outline-container-org2e62903" class="outline-4">
-<h4 id="org2e62903">list</h4>
-<div class="outline-text-4" id="text-org2e62903">
+<div id="outline-container-org6456e5e" class="outline-4">
+<h4 id="org6456e5e">list</h4>
+<div class="outline-text-4" id="text-org6456e5e">
<p>
or ls or l or -l
</p>
@@ -615,9 +636,9 @@ $ ck ls programs -t lisp
</div>
</div>
-<div id="outline-container-org2237d57" class="outline-4">
-<h4 id="org2237d57">search</h4>
-<div class="outline-text-4" id="text-org2237d57">
+<div id="outline-container-orgd015339" class="outline-4">
+<h4 id="orgd015339">search</h4>
+<div class="outline-text-4" id="text-orgd015339">
<p>
or s or -s
</p>
@@ -652,9 +673,9 @@ $ ck search alias
</div>
</div>
-<div id="outline-container-orgbced512" class="outline-4">
-<h4 id="orgbced512">edit</h4>
-<div class="outline-text-4" id="text-orgbced512">
+<div id="outline-container-orgbbfaad1" class="outline-4">
+<h4 id="orgbbfaad1">edit</h4>
+<div class="outline-text-4" id="text-orgbbfaad1">
<p>
or e or -e
</p>
@@ -680,7 +701,7 @@ To do it use:
</div>
</div>
<div id="postamble" class="status">
-<p class="date">Created: 2018-09-26 Wed 12:17</p>
+<p class="date">Created: 2018-09-27 Thu 12:36</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>
diff --git a/README.org b/README.org
index 757b991..aa2ebae 100644
--- a/README.org
+++ b/README.org
@@ -10,38 +10,54 @@
- sqlite3-dev
** compiler
-By default I use clang, if you want to use gcc just
-edit the =CMakeLists.txt= file and change =clang= to =gcc=
+#+BEGIN_SRC sh
+ > export CC=clang
+ # or
+ > export CC=gcc
+#+END_SRC
** make
#+BEGIN_SRC sh
-# clone the repo
-> cd ~/code; git clone https://gitlab.com/grm-grm/ck
-# make a build directory and enter it
-> mkdir ~/ck_build; cd ~/ck_build;
-# run cmake
-> cmake ~/code/ck
-# run make
-> make
-# run ck
-> ./ck
+ # clone the repo
+ > cd ~/code; git clone https://gitlab.com/grm-grm/ck
+ # make a build directory and enter it
+ > mkdir ~/ck_build; cd ~/ck_build;
+ # run cmake
+ > cmake ~/code/ck
+ # run make
+ > make
+ # run ck
+ > ./ck
#+END_SRC
* for devs
-** make
+** CMake options
+cmake accepts the following options:
+#+BEGIN_SRC cmake
+ option(CK_ASAN "Build with asan")
+ option(CK_DEBUG "Build with debug symbols")
+ option(CK_TESTS "Make the tests")
+ option(CK_SHARED "Build with shared lib")
+#+END_SRC
+
+To use any one of them append it after the cmake command like so:
+#+BEGIN_SRC sh
+ cmake -DCK_ASAN=1 -DCK_DEBUG=1 -DCK_TESTS=1 ~/code/ck
+#+END_SRC
+
Just build with address sanitizer enabled like so:
llvm has better asan than gcc, so I use that.
#+BEGIN_SRC sh
-# clone the repo
-> cd ~/code; git clone https://gitlab.com/grm-grm/ck
-# make a build directory and enter it
-> mkdir ~/ck_build; cd ~/ck_build;
-# run cmake
-> cmake ~/code/ck -DCK_ASAN=ON
-# run make
-> make
-# run ck
-> ./ck
+ # clone the repo
+ > cd ~/code; git clone https://gitlab.com/grm-grm/ck
+ # make a build directory and enter it
+ > mkdir ~/ck_build; cd ~/ck_build;
+ # run cmake
+ > cmake -DCK_ASAN=1 -DCK_DEBUG=1 -DCK_TESTS=1 ~/code/ck
+ # run make
+ > make
+ # run ck
+ > ./ck
#+END_SRC
** tests