Browse Source

Small changes to build script for better testing.

enhancement_3
Trevor Irons 8 years ago
parent
commit
787cfb2831
2 changed files with 52 additions and 28 deletions
  1. 40
    17
      CMakeLists.txt
  2. 12
    11
      src/myTestSuite.h

+ 40
- 17
CMakeLists.txt View File

21
 FIND_PROGRAM(HAVEHG hg
21
 FIND_PROGRAM(HAVEHG hg
22
   PATHS /usr/bin/ /bin ENV PATH NO_DEFAULT_PATH
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
 option(BUILD_SHARED_LIBS OFF)
25
 option(BUILD_SHARED_LIBS OFF)
29
 if(BUILD_SHARED_LIBS)
26
 if(BUILD_SHARED_LIBS)
42
 include(ExternalProject)
39
 include(ExternalProject)
43
 # Eigen, this header-library is used extensively for linear algebra, matrices, and arrays
40
 # Eigen, this header-library is used extensively for linear algebra, matrices, and arrays
44
 # Mercurial (hg) repo pull, Would it be better to just download latest stable?
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
 if (HAVEHG)
47
 if (HAVEHG)
46
-ExternalProject_Add(EIGEN
48
+	ExternalProject_Add(EIGEN
47
 	HG_REPOSITORY  "https://bitbucket.org/eigen/eigen/"
49
 	HG_REPOSITORY  "https://bitbucket.org/eigen/eigen/"
48
 	UPDATE_COMMAND ""
50
 	UPDATE_COMMAND ""
49
 	HG_TAG "default"
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
 ELSE() 
55
 ELSE() 
54
-# Stable Eigen, requires manual updating when new releases, but lighter weight.  
56
+# Stable Eigen
55
 ExternalProject_Add(EIGEN
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
 ENDIF()
62
 ENDIF()
63
+include_directories ("${CMAKE_INSTALL_PREFIX}/include/eigen3")
64
+#endif()
62
 
65
 
63
 # Yaml-cpp, this library is used extensively for serialisation of classes (class persistence) 
66
 # Yaml-cpp, this library is used extensively for serialisation of classes (class persistence) 
64
 ExternalProject_Add(YAML-CPP
67
 ExternalProject_Add(YAML-CPP
71
 )
74
 )
72
 add_compile_options(-DHAVE_YAMLCPP) 
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
 # tinyxml2, this library is used for XML IO 
97
 # tinyxml2, this library is used for XML IO 
75
 option( LEMMA_TINYXML_SUPPORT  "MATIO library support for MATLAB .mat files" OFF)
98
 option( LEMMA_TINYXML_SUPPORT  "MATIO library support for MATLAB .mat files" OFF)
76
 if ( LEMMA_TINYXML_SUPPORT )
99
 if ( LEMMA_TINYXML_SUPPORT )
169
 include_directories("${PROJECT_BINARY_DIR}/include")
192
 include_directories("${PROJECT_BINARY_DIR}/include")
170
 
193
 
171
 include_directories ("${PROJECT_SOURCE_DIR}/LemmaCore/include")
194
 include_directories ("${PROJECT_SOURCE_DIR}/LemmaCore/include")
172
-include_directories ("${CMAKE_INSTALL_PREFIX}/include/eigen3")
195
+
173
 include_directories ("${CMAKE_INSTALL_PREFIX}/include/")
196
 include_directories ("${CMAKE_INSTALL_PREFIX}/include/")
174
 link_directories ("${CMAKE_INSTALL_PREFIX}/lib/")
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
 if(CXXTEST_FOUND)
200
 if(CXXTEST_FOUND)
201
+	option (LEMMA_ENABLE_TESTING  "Turn on unit testing" ON)
202
+	if (LEMMA_ENABLE_TESTING)
180
     include_directories(${CXXTEST_INCLUDE_DIR})
203
     include_directories(${CXXTEST_INCLUDE_DIR})
181
     enable_testing()
204
     enable_testing()
182
     #CXXTEST_ADD_TEST(tester_executable runner.cpp
205
     #CXXTEST_ADD_TEST(tester_executable runner.cpp
184
 	CXXTEST_ADD_TEST(unittest_foo foo_test.cc
207
 	CXXTEST_ADD_TEST(unittest_foo foo_test.cc
185
                       ${CMAKE_CURRENT_SOURCE_DIR}/src/myTestSuite.h)
208
                       ${CMAKE_CURRENT_SOURCE_DIR}/src/myTestSuite.h)
186
     #target_link_libraries(unittest_foo foo) # as needed
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
 	endif()
212
 	endif()
190
 endif()
213
 endif()
191
 
214
 

+ 12
- 11
src/myTestSuite.h View File

17
  * @copyright Copyright (c) 2016, Trevor Irons & Lemma Software, LLC
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
 

Loading…
Cancel
Save