From 03917439a1ddcf202e9fc53937b10eeb7ec0a99a Mon Sep 17 00:00:00 2001 From: gramanas Date: Thu, 27 Sep 2018 12:36:54 +0300 Subject: Update CMakeLists and build istructions --- CMakeLists.txt | 53 ++++++++++------- README.html | 179 ++++++++++++++++++++++++++++++++------------------------- README.org | 62 ++++++++++++-------- 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"> - + @@ -232,35 +232,35 @@ for the JavaScript code in this tag.

Table of Contents

-
-

ck

-
+
+

ck

+

The Config Keeper

-
-

build it

-
+
+

build it

+
-
-

requirements

-
+
+

requirements

+
  • clang (llvm) or gcc (gnu)
  • cmake
  • @@ -293,19 +293,21 @@ for the JavaScript code in this tag.
-
-

compiler

-
-

-By default I use clang, if you want to use gcc just -edit the CMakeLists.txt file and change clang to gcc -

+
+

compiler

+
+
+
> export CC=clang
+# or
+> export CC=gcc
+
+
-
-

make

-
+
+

make

+
# clone the repo
 > cd ~/code; git clone https://gitlab.com/grm-grm/ck
@@ -323,13 +325,32 @@ edit the CMakeLists.txt file and change clang to 
 
-
-

for devs

-
+
+

for devs

+
-
-

make

-
+
+

CMake options

+
+

+cmake accepts the following options: +

+
+
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")
+
+
+ +

+To use any one of them append it after the cmake command like so: +

+
+
cmake -DCK_ASAN=1 -DCK_DEBUG=1 -DCK_TESTS=1 ~/code/ck
+
+
+

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. # make a build directory and enter it > mkdir ~/ck_build; cd ~/ck_build; # run cmake -> cmake ~/code/ck -DCK_ASAN=ON +> cmake -DCK_ASAN=1 -DCK_DEBUG=1 -DCK_TESTS=1 ~/code/ck # run make > make # run ck @@ -350,9 +371,9 @@ llvm has better asan than gcc, so I use that.

-
-

tests

-
+
+

tests

+

The testing "suite" is a bash script that runs regression and unit tests. Regression tests are under the tests/ directory @@ -361,9 +382,9 @@ under unit/ directory and test the code.

-
-

run tests

-
+
+

run tests

+

Simply go to the build dir and type.

@@ -374,9 +395,9 @@ Simply go to the build dir and type.
-
-

test suite

-
+
+

test suite

+
$ ./check_ck -h
 ck test suite
@@ -394,9 +415,9 @@ flags:
 
-
-

manual

-
+
+

manual

+

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.

-
-

ck configuration

-
+
+

ck configuration

+

ck uses sqlite to index the configuration files. The init action creates a .ck directory (under $HOME) @@ -490,13 +511,13 @@ $ ck -c /someplace/else ...

-
-

Actions

-
+
+

Actions

+
-
-

init

-
+
+

init

+

or i or -i

@@ -526,9 +547,9 @@ $ ck init /path_to/where_you_want/your_configs/to_be -

add

-
+
+

add

+

or a or -a

@@ -569,9 +590,9 @@ $ ck add program_name config_path [-s] [-p]
-
-

list

-
+
+

list

+

or ls or l or -l

@@ -615,9 +636,9 @@ $ ck ls programs -t lisp
-
-

search

-
+
+

search

+

or s or -s

@@ -652,9 +673,9 @@ $ ck search alias
-
-

edit

-
+
+

edit

+

or e or -e

@@ -680,7 +701,7 @@ To do it use:
-

Created: 2018-09-26 Wed 12:17

+

Created: 2018-09-27 Thu 12:36

Validate

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 -- cgit v1.2.3