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 @@
cmake_minimum_required(VERSION 3.0)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/")
add_definitions(-std=c++11)

project(sqlitepp)

set(SOURCES src/sqlitepp/sqlitepp.cc)
set(TEST_SOURCES src/sqlitepp/sqlitepp_test.cc)
set(LINT_FILES include/sqlitepp/sqlitepp.h ${SOURCES} ${TEST_SOURCES})
set(INCLUDES include)

include(StyleCheck)

include_directories(${INCLUDES})

add_library(sqlitepp ${SOURCES})

find_package(Doxygen)
find_package(Sqlite3 REQUIRED)

set(DEP_INCLUDE_DIRS ${SQLITE3_INCLUDE_DIRS})
set(DEP_LIBRARIES PUBLIC ${SQLITE3_LIBRARIES})

include_directories(${DEP_INCLUDE_DIRS})
target_link_libraries(sqlitepp ${DEP_LIBRARIES})

find_package(GTest)
if(GTEST_FOUND)
enable_testing()
set(TEST_INCLUDE_DIRS ${GTEST_INCLUDE_DIRS})
set(TEST_LIBRARIES ${GTEST_BOTH_LIBRARIES} pthread sqlitepp)
add_executable(sqlitepp_test ${TEST_SOURCES})
include_directories(${TEST_INCLUDE_DIRS})
target_link_libraries(sqlitepp_test ${TEST_LIBRARIES})
set(GTEST_ARGS "")
gtest_add_tests(sqlitepp_test "${GTEST_ARGS}" ${TEST_SOURCES})
endif(GTEST_FOUND)

add_style_check_target(check "${LINT_FILES}")

if(DOXYGEN_FOUND)
configure_file(${CMAKE_MODULE_PATH}/sqlitepp.doxyfile
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
add_custom_target(doc ${DOXYGEN_EXECUTABLE}
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM)
endif(DOXYGEN_FOUND)

+ 0
- 56
CMakeModules/FindSqlite3.cmake View File

@@ -1,56 +0,0 @@
# - find Sqlite 3
# SQLITE3_INCLUDE_DIR - Where to find Sqlite 3 header files (directory)
# SQLITE3_LIBRARIES - Sqlite 3 libraries
# SQLITE3_LIBRARY_RELEASE - Where the release library is
# SQLITE3_LIBRARY_DEBUG - Where the debug library is
# SQLITE3_FOUND - Set to TRUE if we found everything (library, includes and executable)

# Copyright (c) 2010 Pau Garcia i Quiles, <pgquiles@elpauer.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
# Generated by CModuler, a CMake Module Generator - http://gitorious.org/cmoduler

IF( SQLITE3_INCLUDE_DIR AND SQLITE3_LIBRARY_RELEASE AND SQLITE3_LIBRARY_DEBUG )
SET(SQLITE3_FIND_QUIETLY TRUE)
ENDIF( SQLITE3_INCLUDE_DIR AND SQLITE3_LIBRARY_RELEASE AND SQLITE3_LIBRARY_DEBUG )

FIND_PATH( SQLITE3_INCLUDE_DIR sqlite3.h )

FIND_LIBRARY(SQLITE3_LIBRARY_RELEASE NAMES sqlite3 )

FIND_LIBRARY(SQLITE3_LIBRARY_DEBUG NAMES sqlite3 sqlite3d HINTS /usr/lib/debug/usr/lib/ )

IF( SQLITE3_LIBRARY_RELEASE OR SQLITE3_LIBRARY_DEBUG AND SQLITE3_INCLUDE_DIR )
SET( SQLITE3_FOUND TRUE )
ENDIF( SQLITE3_LIBRARY_RELEASE OR SQLITE3_LIBRARY_DEBUG AND SQLITE3_INCLUDE_DIR )

IF( SQLITE3_LIBRARY_DEBUG AND SQLITE3_LIBRARY_RELEASE )
# if the generator supports configuration types then set
# optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
IF( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
SET( SQLITE3_LIBRARIES optimized ${SQLITE3_LIBRARY_RELEASE} debug ${SQLITE3_LIBRARY_DEBUG} )
ELSE( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
# if there are no configuration types and CMAKE_BUILD_TYPE has no value
# then just use the release libraries
SET( SQLITE3_LIBRARIES ${SQLITE3_LIBRARY_RELEASE} )
ENDIF( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE )
ELSEIF( SQLITE3_LIBRARY_RELEASE )
SET( SQLITE3_LIBRARIES ${SQLITE3_LIBRARY_RELEASE} )
ELSE( SQLITE3_LIBRARY_DEBUG AND SQLITE3_LIBRARY_RELEASE )
SET( SQLITE3_LIBRARIES ${SQLITE3_LIBRARY_DEBUG} )
ENDIF( SQLITE3_LIBRARY_DEBUG AND SQLITE3_LIBRARY_RELEASE )

IF( SQLITE3_FOUND )
IF( NOT SQLITE3_FIND_QUIETLY )
MESSAGE( STATUS "Found Sqlite3 header file in ${SQLITE3_INCLUDE_DIR}")
MESSAGE( STATUS "Found Sqlite3 libraries: ${SQLITE3_LIBRARIES}")
ENDIF( NOT SQLITE3_FIND_QUIETLY )
ELSE(SQLITE3_FOUND)
IF( SQLITE3_FIND_REQUIRED)
MESSAGE( FATAL_ERROR "Could not find Sqlite3" )
ELSE( SQLITE3_FIND_REQUIRED)
MESSAGE( STATUS "Optional package Sqlite3 was not found" )
ENDIF( SQLITE3_FIND_REQUIRED)
ENDIF(SQLITE3_FOUND)

+ 0
- 53
CMakeModules/StyleCheck.cmake View File

@@ -1,53 +0,0 @@

# Copyright (C) 2013 Daniel Scharrer
#
# This software is provided 'as-is', without any express or implied
# warranty. In no event will the author(s) be held liable for any damages
# arising from the use of this software.
#
# Permission is granted to anyone to use this software for any purpose,
# including commercial applications, and to alter it and redistribute it
# freely, subject to the following restrictions:
#
# 1. The origin of this software must not be misrepresented; you must not
# claim that you wrote the original software. If you use this software
# in a product, an acknowledgment in the product documentation would be
# appreciated but is not required.
# 2. Altered source versions must be plainly marked as such, and must not be
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
#
#
# Modified 2015 by Robin Krahl -- removed "--filter" and "--project", added
# "--root"
# Original source: https://github.com/dscharrer/innoextract/blob/master/cmake/StyleCheck.cmake

find_package(PythonInterp)

# Add a target that runs cpplint.py
#
# Parameters:
# - TARGET_NAME the name of the target to add
# - SOURCES_LIST a complete list of source and include files to check
function(add_style_check_target TARGET_NAME SOURCES_LIST)
if(NOT PYTHONINTERP_FOUND)
return()
endif()
list(SORT SOURCES_LIST)
list(REMOVE_DUPLICATES SOURCES_LIST)
add_custom_target(${TARGET_NAME}
COMMAND "${CMAKE_COMMAND}" -E chdir
"${CMAKE_SOURCE_DIR}"
"${PYTHON_EXECUTABLE}"
"${CMAKE_MODULE_PATH}/cpplint.py"
"--root=include"
${SOURCES_LIST}
DEPENDS ${SOURCES_LIST}
COMMENT "Checking code style."
VERBATIM
)
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
# will be relative from the directory where doxygen is started.
# This tag requires that the tag FULL_PATH_NAMES is set to YES.

STRIP_FROM_PATH = @CMAKE_CURRENT_SOURCE_DIR@/include \
@CMAKE_CURRENT_SOURCE_DIR@/src
STRIP_FROM_PATH = include src

# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
# 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 \
# specify the list of include paths that are normally passed to the compiler
# using the -I flag.

STRIP_FROM_INC_PATH = @CMAKE_CURRENT_SOURCE_DIR@/include
STRIP_FROM_INC_PATH = include

# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but
# less readable) file names. This can be useful is your file systems doesn't
@@ -759,8 +758,7 @@ WARN_LOGFILE =
# spaces.
# Note: If this tag is empty the current directory is searched.

INPUT = @CMAKE_CURRENT_SOURCE_DIR@/src/ \
@CMAKE_CURRENT_SOURCE_DIR@/include/
INPUT = src/ include/

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses

+ 70
- 0
Makefile View File

@@ -0,0 +1,70 @@
include config.mk

INCLUDE_DIR := include
SOURCE_DIR := src
OBJECT_DIR := obj
LIBRARY_DIR := lib
BINARY_DIR := bin
DOCUMENTATION_DIR := doc

SOURCE_NAMES_LIB := sqlitepp.cc
SOURCE_NAMES_TEST := sqlitepp_test.cc
TARGETS := $(LIBRARY_DIR)/libsqlitepp.so $(BINARY_DIR)/sqlitepp_test

SOURCES_LIB := $(foreach source,$(SOURCE_NAMES_LIB),$(SOURCE_DIR)/sqlitepp/$(source))
OBJECTS_LIB := $(SOURCES_LIB:$(SOURCE_DIR)/%.cc=$(OBJECT_DIR)/%.o)
DEPENDS_LIB := $(OBJECTS_LIB:.o=.d)

SOURCES_TEST := $(foreach source,$(SOURCE_NAMES_TEST),$(SOURCE_DIR)/sqlitepp/$(source))
OBJECTS_TEST := $(SOURCES_TEST:$(SOURCE_DIR)/%.cc=$(OBJECT_DIR)/%.o)
DEPENDS_TEST := $(OBJECTS_TEST:.o=.d)

INCLUDES := $(INCLUDE_DIR)/sqlitepp/sqlitepp.h
OBJECTS := $(OBJECTS_LIB) $(OBJECTS_TEST)
DEPENDS := $(DEPENDS_LIB) $(DEPENDS_TEST)

CPPFLAGS += -MMD -MP -I$(INCLUDE_DIR)
CXXFLAGS += -fPIC
LDFLAGS += $(LDFLAGS_SQLITE3)
LDFLAGS_TEST += -L$(LIBRARY_DIR) -lsqlitepp $(LDFLAGS_GTEST)

ifdef VERBOSE
QUIET :=
else
QUIET := @
endif

.PHONY = all clean doc

all: $(TARGETS)

clean:
$(info (RM) $(OBJECT_DIR))
$(QUIET)$(RM) -r $(OBJECT_DIR)
$(info (RM) $(LIBRARY_DIR))
$(QUIET)$(RM) -r $(LIBRARY_DIR)
$(info (RM) $(BINARY_DIR))
$(QUIET)$(RM) -r $(BINARY_DIR)
$(info (RM) $(DOCUMENTATION_DIR))
$(QUIET)$(RM) -r $(DOCUMENTATION_DIR)

doc: $(INCLUDES)
doxygen

$(LIBRARY_DIR)/libsqlitepp.so: $(OBJECTS_LIB)
$(info (CXX) $@)
$(QUIET)mkdir -p $(LIBRARY_DIR)
$(QUIET)$(CXX) -shared $(LDFLAGS) $(LDFLAGS_LIB) -o $@ $^

$(BINARY_DIR)/sqlitepp_test: $(OBJECTS_TEST)
$(info (CXX) $@)
$(QUIET)mkdir -p $(BINARY_DIR)
$(QUIET)$(CXX) $(LDFLAGS) $(LDFLAGS_TEST) $< -o $@

$(OBJECTS): $(OBJECT_DIR)/%.o: $(SOURCE_DIR)/%.cc
$(info (CXX) $@)
$(QUIET)mkdir -p $(OBJECT_DIR)
$(QUIET)mkdir -p $(OBJECT_DIR)/sqlitepp
$(QUIET)$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@

-include $(DEPENDS)

+ 0
- 1
README.md View File

@@ -7,7 +7,6 @@ Dependencies
------------

- required dependencies
- CMake 3.0 (or later)
- libsqlite3
- optional dependencies
- libgtest (for tests)

+ 5
- 0
config.mk View File

@@ -0,0 +1,5 @@
LDFLAGS_SQLITE3 += -lsqlite3
LDFLAGS_GTEST += -lgtest -lgtest_main

CPPFLAGS +=
CXXFLAGS += -std=c++11 -Wall -Wextra

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

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

Loading…
Cancel
Save