Pārlūkot izejas kodu

Small changes to build script for better testing.

enhancement_3
Trevor Irons 8 gadus atpakaļ
vecāks
revīzija
787cfb2831
2 mainītis faili ar 52 papildinājumiem un 28 dzēšanām
  1. 40
    17
      CMakeLists.txt
  2. 12
    11
      src/myTestSuite.h

+ 40
- 17
CMakeLists.txt Parādīt failu

@@ -21,9 +21,6 @@ endif(NOT HAVEGIT)
21 21
 FIND_PROGRAM(HAVEHG hg
22 22
   PATHS /usr/bin/ /bin ENV PATH NO_DEFAULT_PATH
23 23
 )
24
-if(NOT HAVEHG)
25
-   message(STATUS "Mercurial (hg) was not found.")
26
-endif(NOT HAVEHG)
27 24
 
28 25
 option(BUILD_SHARED_LIBS OFF)
29 26
 if(BUILD_SHARED_LIBS)
@@ -42,23 +39,29 @@ endif()
42 39
 include(ExternalProject)
43 40
 # Eigen, this header-library is used extensively for linear algebra, matrices, and arrays
44 41
 # Mercurial (hg) repo pull, Would it be better to just download latest stable?
42
+#find_package(Eigen3 REQUIRED)
43
+#if (EIGEN3_FOUND)
44
+#	# do nothing
45
+#	include_directories(EIGEN3_INCLUDE_DIR)
46
+#else() 
45 47
 if (HAVEHG)
46
-ExternalProject_Add(EIGEN
48
+	ExternalProject_Add(EIGEN
47 49
 	HG_REPOSITORY  "https://bitbucket.org/eigen/eigen/"
48 50
 	UPDATE_COMMAND ""
49 51
 	HG_TAG "default"
50
-    PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
51
-    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
52
+   	PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
53
+   	CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
52 54
 )
53 55
 ELSE() 
54
-# Stable Eigen, requires manual updating when new releases, but lighter weight.  
56
+# Stable Eigen
55 57
 ExternalProject_Add(EIGEN
56
-    #URL "http://bitbucket.org/eigen/eigen/get/3.2.7.tar.gz"
57
-    URL "http://bitbucket.org/eigen/eigen/get/default.tar.gz" # tip from repo
58
-    PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
59
-    CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
58
+   	URL "http://bitbucket.org/eigen/eigen/get/default.tar.gz" # tip from repo
59
+   	PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
60
+   	CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
60 61
 )
61 62
 ENDIF()
63
+include_directories ("${CMAKE_INSTALL_PREFIX}/include/eigen3")
64
+#endif()
62 65
 
63 66
 # Yaml-cpp, this library is used extensively for serialisation of classes (class persistence) 
64 67
 ExternalProject_Add(YAML-CPP
@@ -71,6 +74,26 @@ ExternalProject_Add(YAML-CPP
71 74
 )
72 75
 add_compile_options(-DHAVE_YAMLCPP) 
73 76
 
77
+# CxxTest 
78
+find_package(CxxTest) 
79
+if (CXXTEST_FOUND)
80
+	# Do nothing
81
+else()
82
+	ExternalProject_Add(CxxTest
83
+		GIT_REPOSITORY "https://github.com/CxxTest/cxxtest.git"
84
+		GIT_TAG "master"
85
+		UPDATE_COMMAND ""
86
+		PATCH_COMMAND ""
87
+		CONFIGURE_COMMAND ""
88
+		BUILD_COMMAND ""
89
+		INSTALL_COMMAND ""
90
+    	PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest
91
+	)
92
+	set (CXXTEST_INCLUDE_DIR  "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/")
93
+	set (CXXTEST_PYTHON_TESTGEN_EXECUTABLE "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/bin/cxxtestgen" )
94
+	find_package(CxxTest REQUIRED)
95
+endif()
96
+
74 97
 # tinyxml2, this library is used for XML IO 
75 98
 option( LEMMA_TINYXML_SUPPORT  "MATIO library support for MATLAB .mat files" OFF)
76 99
 if ( LEMMA_TINYXML_SUPPORT )
@@ -169,14 +192,14 @@ configure_file (
169 192
 include_directories("${PROJECT_BINARY_DIR}/include")
170 193
 
171 194
 include_directories ("${PROJECT_SOURCE_DIR}/LemmaCore/include")
172
-include_directories ("${CMAKE_INSTALL_PREFIX}/include/eigen3")
195
+
173 196
 include_directories ("${CMAKE_INSTALL_PREFIX}/include/")
174 197
 link_directories ("${CMAKE_INSTALL_PREFIX}/lib/")
175 198
 
176
-option (LEMMA_ENABLE_TESTING  "Turn on unit testing" ON)
177
-if (LEMMA_ENABLE_TESTING)
178
-find_package(CxxTest REQUIRED)
199
+
179 200
 if(CXXTEST_FOUND)
201
+	option (LEMMA_ENABLE_TESTING  "Turn on unit testing" ON)
202
+	if (LEMMA_ENABLE_TESTING)
180 203
     include_directories(${CXXTEST_INCLUDE_DIR})
181 204
     enable_testing()
182 205
     #CXXTEST_ADD_TEST(tester_executable runner.cpp
@@ -184,8 +207,8 @@ if(CXXTEST_FOUND)
184 207
 	CXXTEST_ADD_TEST(unittest_foo foo_test.cc
185 208
                       ${CMAKE_CURRENT_SOURCE_DIR}/src/myTestSuite.h)
186 209
     #target_link_libraries(unittest_foo foo) # as needed
187
-	else()
188
-	message(FATAL_ERROR "CxxTest not found.")
210
+#	else()
211
+#	message(FATAL_ERROR "CxxTest not found.")
189 212
 	endif()
190 213
 endif()
191 214
 

+ 12
- 11
src/myTestSuite.h Parādīt failu

@@ -17,16 +17,17 @@
17 17
  * @copyright Copyright (c) 2016, Trevor Irons & Lemma Software, LLC
18 18
  */
19 19
 
20
-          // MyTestSuite.h
21
-          #include <cxxtest/TestSuite.h>
20
+// MyTestSuite.h
21
+#include <cxxtest/TestSuite.h>
22 22
 
23
-          class MyTestSuite : public CxxTest::TestSuite
24
-          {
25
-          public:
26
-             void testAddition( void )
27
-             {
28
-                TS_ASSERT( 1 + 1 > 1 );
29
-                TS_ASSERT_EQUALS( 1 + 1, 2 );
30
-             }
31
-          };
23
+class MyTestSuite : public CxxTest::TestSuite
24
+{
25
+    public:
26
+    void testAddition( void )
27
+    {
28
+        TS_ASSERT( 1 + 1 > 1 );
29
+        TS_ASSERT( 1 - 1 > 1 );
30
+        TS_ASSERT_EQUALS( 1 + 1, 2 );
31
+    }
32
+};
32 33
 

Notiek ielāde…
Atcelt
Saglabāt