Robin Thoni преди 8 години
родител
ревизия
84877ee20f
променени са 3 файла, в които са добавени 58 реда и са изтрити 7 реда
  1. 7
    4
      CMakeLists.txt
  2. 46
    0
      CMakeModules/FindJsonCpp.cmake
  3. 5
    3
      src/CMakeLists.txt

+ 7
- 4
CMakeLists.txt Целия файл

@@ -1,7 +1,10 @@
1 1
 cmake_minimum_required(VERSION 2.8)
2
-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/")
2
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/")
3 3
 project(pdns-slave)
4
-find_package(GTest REQUIRED)
5
-enable_testing()
4
+find_package(JsonCpp REQUIRED)
5
+find_package(GTest)
6 6
 add_subdirectory(src)
7
-add_subdirectory(tests)
7
+if (GTEST_FOUND)
8
+    enable_testing()
9
+    add_subdirectory(tests)
10
+endif (GTEST_FOUND)

+ 46
- 0
CMakeModules/FindJsonCpp.cmake Целия файл

@@ -0,0 +1,46 @@
1
+# -*- cmake -*-
2
+# - Find JSONCpp
3
+# Find the JSONCpp includes and library
4
+# This module defines
5
+#  JSONCPP_INCLUDE_DIRS, where to find json.h, etc.
6
+#  JSONCPP_LIBRARIES, the libraries needed to use jsoncpp.
7
+#  JSONCPP_FOUND, If false, do not try to use jsoncpp.
8
+#  also defined, but not for general use are
9
+#  JSONCPP_LIBRARIES, where to find the jsoncpp library.
10
+
11
+FIND_PATH(JSONCPP_INCLUDE_DIRS json/json.h
12
+        /usr/include
13
+        /usr/local/include
14
+        ${CMAKE_SOURCE_DIR}/win32-deps/include
15
+        PATH_SUFFIXES jsoncpp/json jsoncpp
16
+        )
17
+
18
+
19
+FIND_LIBRARY(JSONCPP_LIBRARIES NAMES jsoncpp HINTS /usr/lib /usr/local/lib 	${CMAKE_SOURCE_DIR}/win32-deps/lib)
20
+
21
+IF (JSONCPP_LIBRARIES AND JSONCPP_INCLUDE_DIRS)
22
+    SET(JSONCPP_LIBRARIES ${JSONCPP_LIBRARIES})
23
+    SET(JSONCPP_FOUND "YES")
24
+ELSE (JSONCPP_LIBRARIES AND JSONCPP_INCLUDE_DIRS)
25
+    SET(JSONCPP_FOUND "NO")
26
+ENDIF (JSONCPP_LIBRARIES AND JSONCPP_INCLUDE_DIRS)
27
+
28
+
29
+IF (JSONCPP_FOUND)
30
+    IF (NOT JSONCPP_FIND_QUIETLY)
31
+        MESSAGE(STATUS "Found JSONCpp: ${JSONCPP_LIBRARIES}")
32
+    ENDIF (NOT JSONCPP_FIND_QUIETLY)
33
+ELSE (JSONCPP_FOUND)
34
+    IF (JSONCPP_FIND_REQUIRED)
35
+        MESSAGE(FATAL_ERROR "Could not find JSONCPP library include: ${JSONCPP_INCLUDE_DIRS}, lib: ${JSONCPP_LIBRARIES}")
36
+    ENDIF (JSONCPP_FIND_REQUIRED)
37
+ENDIF (JSONCPP_FOUND)
38
+
39
+# Deprecated declarations.
40
+SET (NATIVE_JSONCPP_INCLUDE_PATH ${JSONCPP_INCLUDE_DIRS} )
41
+GET_FILENAME_COMPONENT (NATIVE_JSONCPP_LIB_PATH ${JSONCPP_LIBRARIES} PATH)
42
+
43
+MARK_AS_ADVANCED(
44
+        JSONCPP_LIBRARIES
45
+        JSONCPP_INCLUDE_DIRS
46
+)

+ 5
- 3
src/CMakeLists.txt Целия файл

@@ -1,5 +1,5 @@
1 1
 include_directories(.)
2
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
2
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -I${JSONCPP_INCLUDE_DIRS}")
3 3
 set(SOURCE_FILES
4 4
   main.cpp
5 5
   Interface/MainClass.cpp
@@ -12,6 +12,8 @@ set(SOURCE_FILES
12 12
   DataAccess/PdnsSlaveConfig.h
13 13
   DataAccess/HostsConfig.cpp
14 14
   DataAccess/HostsConfig.h
15
+  DataAccess/MySql.cpp
16
+  DataAccess/MySql.h
15 17
   DBO/CommandLineOption.cpp
16 18
   DBO/CommandLineOption.h
17 19
   DBO/SqlConfiguration.cpp
@@ -28,7 +30,7 @@ set(SOURCE_FILES
28 30
   DBO/Actions/ActionDelDomain.h
29 31
   DBO/Actions/ActionAddDomain.cpp
30 32
   DBO/Actions/ActionAddDomain.h
31
-  )
33
+        DataAccess/AbstractSql.cpp DataAccess/AbstractSql.h)
32 34
 set(LIBS ${LIBS} jsoncpp)
33
-add_executable(pdns-slave ${SOURCE_FILES} DataAccess/MySql.cpp DataAccess/MySql.h)
35
+add_executable(pdns-slave ${SOURCE_FILES})
34 36
 target_link_libraries(pdns-slave ${LIBS})

Loading…
Отказ
Запис