Browse Source

Move from CMake to a plain Makefile

The Makefile contains the rules to build both the library and the test
binary, and to create the HTML and LaTeX documentation.  Settings like
library paths and compiler options are set in config.mk.
master
Robin Krahl 2 years ago
parent
commit
cbe3dc9f40
9 changed files with 81 additions and 6493 deletions
  1. 0
    49
      CMakeLists.txt
  2. 0
    56
      CMakeModules/FindSqlite3.cmake
  3. 0
    53
      CMakeModules/StyleCheck.cmake
  4. 0
    6323
      CMakeModules/cpplint.py
  5. 3
    5
      Doxyfile
  6. 70
    0
      Makefile
  7. 0
    1
      README.md
  8. 5
    0
      config.mk
  9. 3
    6
      include/sqlitepp/sqlitepp.h

+ 0
- 49
CMakeLists.txt View File

@@ -1,49 +0,0 @@
1
-cmake_minimum_required(VERSION 3.0)
2
-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/")
3
-add_definitions(-std=c++11)
4
-
5
-project(sqlitepp)
6
-
7
-set(SOURCES src/sqlitepp/sqlitepp.cc)
8
-set(TEST_SOURCES src/sqlitepp/sqlitepp_test.cc)
9
-set(LINT_FILES include/sqlitepp/sqlitepp.h ${SOURCES} ${TEST_SOURCES})
10
-set(INCLUDES include)
11
-
12
-include(StyleCheck)
13
-
14
-include_directories(${INCLUDES})
15
-
16
-add_library(sqlitepp ${SOURCES})
17
-
18
-find_package(Doxygen)
19
-find_package(Sqlite3 REQUIRED)
20
-
21
-set(DEP_INCLUDE_DIRS ${SQLITE3_INCLUDE_DIRS})
22
-set(DEP_LIBRARIES PUBLIC ${SQLITE3_LIBRARIES})
23
-
24
-include_directories(${DEP_INCLUDE_DIRS})
25
-target_link_libraries(sqlitepp ${DEP_LIBRARIES})
26
-
27
-find_package(GTest)
28
-if(GTEST_FOUND)
29
-  enable_testing()
30
-  set(TEST_INCLUDE_DIRS ${GTEST_INCLUDE_DIRS})
31
-  set(TEST_LIBRARIES ${GTEST_BOTH_LIBRARIES} pthread sqlitepp)
32
-  add_executable(sqlitepp_test ${TEST_SOURCES})
33
-  include_directories(${TEST_INCLUDE_DIRS})
34
-  target_link_libraries(sqlitepp_test ${TEST_LIBRARIES})
35
-  set(GTEST_ARGS "")
36
-  gtest_add_tests(sqlitepp_test "${GTEST_ARGS}" ${TEST_SOURCES})
37
-endif(GTEST_FOUND)
38
-
39
-add_style_check_target(check "${LINT_FILES}")
40
-
41
-if(DOXYGEN_FOUND)
42
-  configure_file(${CMAKE_MODULE_PATH}/sqlitepp.doxyfile
43
-    ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
44
-  add_custom_target(doc ${DOXYGEN_EXECUTABLE}
45
-    ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
46
-    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
47
-    COMMENT "Generating API documentation with Doxygen"
48
-    VERBATIM)
49
-endif(DOXYGEN_FOUND)

+ 0
- 56
CMakeModules/FindSqlite3.cmake View File

@@ -1,56 +0,0 @@
1
-# - find Sqlite 3
2
-# SQLITE3_INCLUDE_DIR - Where to find Sqlite 3 header files (directory)
3
-# SQLITE3_LIBRARIES - Sqlite 3 libraries
4
-# SQLITE3_LIBRARY_RELEASE - Where the release library is
5
-# SQLITE3_LIBRARY_DEBUG - Where the debug library is
6
-# SQLITE3_FOUND - Set to TRUE if we found everything (library, includes and executable)
7
-
8
-# Copyright (c) 2010 Pau Garcia i Quiles, <pgquiles@elpauer.org>
9
-#
10
-# Redistribution and use is allowed according to the terms of the BSD license.
11
-# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
12
-#
13
-# Generated by CModuler, a CMake Module Generator - http://gitorious.org/cmoduler
14
-
15
-IF( SQLITE3_INCLUDE_DIR AND SQLITE3_LIBRARY_RELEASE AND SQLITE3_LIBRARY_DEBUG )
16
-    SET(SQLITE3_FIND_QUIETLY TRUE)
17
-ENDIF( SQLITE3_INCLUDE_DIR AND SQLITE3_LIBRARY_RELEASE AND SQLITE3_LIBRARY_DEBUG )
18
-
19
-FIND_PATH( SQLITE3_INCLUDE_DIR sqlite3.h  )
20
-
21
-FIND_LIBRARY(SQLITE3_LIBRARY_RELEASE NAMES sqlite3 )
22
-
23
-FIND_LIBRARY(SQLITE3_LIBRARY_DEBUG NAMES sqlite3 sqlite3d  HINTS /usr/lib/debug/usr/lib/ )
24
-
25
-IF( SQLITE3_LIBRARY_RELEASE OR SQLITE3_LIBRARY_DEBUG AND SQLITE3_INCLUDE_DIR )
26
-	SET( SQLITE3_FOUND TRUE )
27
-ENDIF( SQLITE3_LIBRARY_RELEASE OR SQLITE3_LIBRARY_DEBUG AND SQLITE3_INCLUDE_DIR )
28
-
29
-IF( SQLITE3_LIBRARY_DEBUG AND SQLITE3_LIBRARY_RELEASE )
30
-	# if the generator supports configuration types then set
31
-	# optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
32
-	IF( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
33
-		SET( SQLITE3_LIBRARIES optimized ${SQLITE3_LIBRARY_RELEASE} debug ${SQLITE3_LIBRARY_DEBUG} )
34
-	ELSE( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
35
-    # if there are no configuration types and CMAKE_BUILD_TYPE has no value
36
-    # then just use the release libraries
37
-		SET( SQLITE3_LIBRARIES ${SQLITE3_LIBRARY_RELEASE} )
38
-	ENDIF( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
39
-ELSEIF( SQLITE3_LIBRARY_RELEASE )
40
-	SET( SQLITE3_LIBRARIES ${SQLITE3_LIBRARY_RELEASE} )
41
-ELSE( SQLITE3_LIBRARY_DEBUG AND SQLITE3_LIBRARY_RELEASE )
42
-	SET( SQLITE3_LIBRARIES ${SQLITE3_LIBRARY_DEBUG} )
43
-ENDIF( SQLITE3_LIBRARY_DEBUG AND SQLITE3_LIBRARY_RELEASE )
44
-
45
-IF( SQLITE3_FOUND )
46
-	IF( NOT SQLITE3_FIND_QUIETLY )
47
-		MESSAGE( STATUS "Found Sqlite3 header file in ${SQLITE3_INCLUDE_DIR}")
48
-		MESSAGE( STATUS "Found Sqlite3 libraries: ${SQLITE3_LIBRARIES}")
49
-	ENDIF( NOT SQLITE3_FIND_QUIETLY )
50
-ELSE(SQLITE3_FOUND)
51
-	IF( SQLITE3_FIND_REQUIRED)
52
-		MESSAGE( FATAL_ERROR "Could not find Sqlite3" )
53
-	ELSE( SQLITE3_FIND_REQUIRED)
54
-		MESSAGE( STATUS "Optional package Sqlite3 was not found" )
55
-	ENDIF( SQLITE3_FIND_REQUIRED)
56
-ENDIF(SQLITE3_FOUND)

+ 0
- 53
CMakeModules/StyleCheck.cmake View File

@@ -1,53 +0,0 @@
1
-
2
-# Copyright (C) 2013 Daniel Scharrer
3
-#
4
-# This software is provided 'as-is', without any express or implied
5
-# warranty.  In no event will the author(s) be held liable for any damages
6
-# arising from the use of this software.
7
-#
8
-# Permission is granted to anyone to use this software for any purpose,
9
-# including commercial applications, and to alter it and redistribute it
10
-# freely, subject to the following restrictions:
11
-#
12
-# 1. The origin of this software must not be misrepresented; you must not
13
-#    claim that you wrote the original software. If you use this software
14
-#    in a product, an acknowledgment in the product documentation would be
15
-#    appreciated but is not required.
16
-# 2. Altered source versions must be plainly marked as such, and must not be
17
-#    misrepresented as being the original software.
18
-# 3. This notice may not be removed or altered from any source distribution.
19
-#
20
-#
21
-# Modified 2015 by Robin Krahl -- removed "--filter" and "--project", added
22
-# "--root"
23
-# Original source: https://github.com/dscharrer/innoextract/blob/master/cmake/StyleCheck.cmake
24
-
25
-find_package(PythonInterp)
26
-
27
-# Add a target that runs cpplint.py
28
-#
29
-# Parameters:
30
-# - TARGET_NAME the name of the target to add
31
-# - SOURCES_LIST a complete list of source and include files to check
32
-function(add_style_check_target TARGET_NAME SOURCES_LIST)
33
-	
34
-	if(NOT PYTHONINTERP_FOUND)
35
-		return()
36
-	endif()
37
-	
38
-	list(SORT SOURCES_LIST)
39
-	list(REMOVE_DUPLICATES SOURCES_LIST)
40
-	
41
-	add_custom_target(${TARGET_NAME}
42
-		COMMAND "${CMAKE_COMMAND}" -E chdir
43
-			"${CMAKE_SOURCE_DIR}"
44
-			"${PYTHON_EXECUTABLE}"
45
-			"${CMAKE_MODULE_PATH}/cpplint.py"
46
-      "--root=include"
47
-			${SOURCES_LIST}
48
-		DEPENDS ${SOURCES_LIST}
49
-		COMMENT "Checking code style."
50
-		VERBATIM
51
-	)
52
-	
53
-endfunction(add_style_check_target)

+ 0
- 6323
CMakeModules/cpplint.py
File diff suppressed because it is too large
View File


CMakeModules/sqlitepp.doxyfile → Doxyfile View File

@@ -152,8 +152,7 @@ FULL_PATH_NAMES        = YES
152 152
 # will be relative from the directory where doxygen is started.
153 153
 # This tag requires that the tag FULL_PATH_NAMES is set to YES.
154 154
 
155
-STRIP_FROM_PATH        = @CMAKE_CURRENT_SOURCE_DIR@/include \
156
-                         @CMAKE_CURRENT_SOURCE_DIR@/src
155
+STRIP_FROM_PATH        = include src
157 156
 
158 157
 # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
159 158
 # path mentioned in the documentation of a class, which tells the reader which
@@ -162,7 +161,7 @@ STRIP_FROM_PATH        = @CMAKE_CURRENT_SOURCE_DIR@/include \
162 161
 # specify the list of include paths that are normally passed to the compiler
163 162
 # using the -I flag.
164 163
 
165
-STRIP_FROM_INC_PATH    = @CMAKE_CURRENT_SOURCE_DIR@/include
164
+STRIP_FROM_INC_PATH    = include
166 165
 
167 166
 # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but
168 167
 # less readable) file names. This can be useful is your file systems doesn't
@@ -759,8 +758,7 @@ WARN_LOGFILE           =
759 758
 # spaces.
760 759
 # Note: If this tag is empty the current directory is searched.
761 760
 
762
-INPUT                  = @CMAKE_CURRENT_SOURCE_DIR@/src/ \
763
-                         @CMAKE_CURRENT_SOURCE_DIR@/include/
761
+INPUT                  = src/ include/
764 762
 
765 763
 # This tag can be used to specify the character encoding of the source files
766 764
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses

+ 70
- 0
Makefile View File

@@ -0,0 +1,70 @@
1
+include config.mk
2
+
3
+INCLUDE_DIR := include
4
+SOURCE_DIR := src
5
+OBJECT_DIR := obj
6
+LIBRARY_DIR := lib
7
+BINARY_DIR := bin
8
+DOCUMENTATION_DIR := doc
9
+
10
+SOURCE_NAMES_LIB := sqlitepp.cc
11
+SOURCE_NAMES_TEST := sqlitepp_test.cc
12
+TARGETS := $(LIBRARY_DIR)/libsqlitepp.so $(BINARY_DIR)/sqlitepp_test
13
+
14
+SOURCES_LIB := $(foreach source,$(SOURCE_NAMES_LIB),$(SOURCE_DIR)/sqlitepp/$(source))
15
+OBJECTS_LIB := $(SOURCES_LIB:$(SOURCE_DIR)/%.cc=$(OBJECT_DIR)/%.o)
16
+DEPENDS_LIB := $(OBJECTS_LIB:.o=.d)
17
+
18
+SOURCES_TEST := $(foreach source,$(SOURCE_NAMES_TEST),$(SOURCE_DIR)/sqlitepp/$(source))
19
+OBJECTS_TEST := $(SOURCES_TEST:$(SOURCE_DIR)/%.cc=$(OBJECT_DIR)/%.o)
20
+DEPENDS_TEST := $(OBJECTS_TEST:.o=.d)
21
+
22
+INCLUDES := $(INCLUDE_DIR)/sqlitepp/sqlitepp.h
23
+OBJECTS := $(OBJECTS_LIB) $(OBJECTS_TEST)
24
+DEPENDS := $(DEPENDS_LIB) $(DEPENDS_TEST)
25
+
26
+CPPFLAGS += -MMD -MP -I$(INCLUDE_DIR)
27
+CXXFLAGS += -fPIC
28
+LDFLAGS += $(LDFLAGS_SQLITE3)
29
+LDFLAGS_TEST += -L$(LIBRARY_DIR) -lsqlitepp $(LDFLAGS_GTEST)
30
+
31
+ifdef VERBOSE
32
+	QUIET :=
33
+else
34
+	QUIET := @
35
+endif
36
+
37
+.PHONY = all clean doc
38
+
39
+all: $(TARGETS)
40
+
41
+clean:
42
+	$(info (RM)    $(OBJECT_DIR))
43
+	$(QUIET)$(RM) -r $(OBJECT_DIR)
44
+	$(info (RM)    $(LIBRARY_DIR))
45
+	$(QUIET)$(RM) -r $(LIBRARY_DIR)
46
+	$(info (RM)    $(BINARY_DIR))
47
+	$(QUIET)$(RM) -r $(BINARY_DIR)
48
+	$(info (RM)    $(DOCUMENTATION_DIR))
49
+	$(QUIET)$(RM) -r $(DOCUMENTATION_DIR)
50
+
51
+doc: $(INCLUDES)
52
+	doxygen
53
+
54
+$(LIBRARY_DIR)/libsqlitepp.so: $(OBJECTS_LIB)
55
+	$(info (CXX)   $@)
56
+	$(QUIET)mkdir -p $(LIBRARY_DIR)
57
+	$(QUIET)$(CXX) -shared $(LDFLAGS) $(LDFLAGS_LIB) -o $@ $^
58
+
59
+$(BINARY_DIR)/sqlitepp_test: $(OBJECTS_TEST)
60
+	$(info (CXX)    $@)
61
+	$(QUIET)mkdir -p $(BINARY_DIR)
62
+	$(QUIET)$(CXX) $(LDFLAGS) $(LDFLAGS_TEST) $< -o $@
63
+
64
+$(OBJECTS): $(OBJECT_DIR)/%.o: $(SOURCE_DIR)/%.cc
65
+	$(info (CXX)   $@)
66
+	$(QUIET)mkdir -p $(OBJECT_DIR)
67
+	$(QUIET)mkdir -p $(OBJECT_DIR)/sqlitepp
68
+	$(QUIET)$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
69
+
70
+-include $(DEPENDS)

+ 0
- 1
README.md View File

@@ -7,7 +7,6 @@ Dependencies
7 7
 ------------
8 8
 
9 9
  - required dependencies
10
-   - CMake 3.0 (or later)
11 10
    - libsqlite3
12 11
  - optional dependencies
13 12
    - libgtest (for tests)

+ 5
- 0
config.mk View File

@@ -0,0 +1,5 @@
1
+LDFLAGS_SQLITE3 += -lsqlite3
2
+LDFLAGS_GTEST += -lgtest -lgtest_main
3
+
4
+CPPFLAGS +=
5
+CXXFLAGS += -std=c++11 -Wall -Wextra

+ 3
- 6
include/sqlitepp/sqlitepp.h View File

@@ -17,12 +17,9 @@
17 17
 /// **sqlitepp** is a C++ wrapper for the official SQLite3 C API.
18 18
 ///
19 19
 /// \section compile Compiling sqlitepp
20
-/// sqlitepp uses CMake as a build tool. To build sqlitepp from source,
21
-/// download the source from GitHub and then execute these commands:
22
-/// \code
23
-/// $ mkdir bin && cd bin
24
-/// $ cmake .. && make
25
-/// \endcode
20
+/// sqlitepp uses GNU Make as a build tool. To build sqlitepp from source,
21
+/// download the source from GitHub and then run `make`.  You might have to
22
+/// settings in `config.mk`.
26 23
 ///
27 24
 /// \section using Using sqlitepp
28 25
 ///

Loading…
Cancel
Save