Kaynağa Gözat

Clean up of build script for cxxtest

lagkey
T-bone 6 yıl önce
ebeveyn
işleme
3836ac84ef
2 değiştirilmiş dosya ile 54 ekleme ve 35 silme
  1. 18
    6
      CMake/SuperBuild.cmake
  2. 36
    29
      CMakeLists.txt

+ 18
- 6
CMake/SuperBuild.cmake Dosyayı Görüntüle

@@ -1,6 +1,6 @@
1 1
 include(ExternalProject)
2 2
 
3
-if (eigen3_FOUND)
3
+if (Eigen3_FOUND)
4 4
     message( STATUS "Eigen was found ${eigen_DIR}" )
5 5
 else()
6 6
     message( STATUS "Eigen WAS NOT FOUND ${eigen_DIR}" )
@@ -14,7 +14,11 @@ else()
14 14
 		#BUILD_COMMAND     ""
15 15
 		#INSTALL_COMMAND     ""
16 16
     )
17
-    
17
+
18
+    message("Source dir of myExtProj = ${SOURCE_DIR}")   
19
+    ExternalProject_Get_property(EIGEN SOURCE_DIR)
20
+    message("Source dir of myExtProj = ${SOURCE_DIR}")   
21
+ 
18 22
     # Are these necessary?
19 23
     #include_directories ("${CMAKE_INSTALL_PREFIX}/include/eigen3/")
20 24
     #set (Eigen3_DIR  "${CMAKE_INSTALL_PREFIX}/include/eigen3" CACHE  PATH "" FORCE )
@@ -39,13 +43,14 @@ else()
39 43
 		GIT_TAG   "yaml-cpp-0.6.1" # "master" 
40 44
 		UPDATE_COMMAND ""
41 45
 		PATCH_COMMAND ""
42
-		INSTALL_COMMAND ""
43 46
     	PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/yaml-cpp
44 47
     	CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} 
45 48
                    -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} 
46
-                   -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 
47 49
     	           -DYAML_CPP_BUILD_TESTS=OFF
50
+                   -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 
51
+		#INSTALL_COMMAND ""
48 52
 	)	
53
+
49 54
     # is this necessary?
50 55
 	#include_directories ("${CMAKE_INSTALL_PREFIX}/include/yaml-cpp")
51 56
 endif()
@@ -77,8 +82,7 @@ if (LEMMA_ENABLE_TESTING)
77 82
 	    # The values "CACHE PATH "" FORCE" makes the GUI show the values of the local CxxTest, but this can cause issues 
78 83
 	    # with users wanting to specify their own path. However, the SuperBuild needs this, in theory you are only here 
79 84
         # because a usable CXXTEST was not already found on the machine, so likely this is sane to do 
80
-	    #set (CXXTEST_INCLUDE_DIR  "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/"  CACHE PATH "" FORCE )
81
-	    #set (CXXTEST_PYTHON_TESTGEN_EXECUTABLE "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/bin/cxxtestgen" CACHE PATH "" FORCE )
85
+
82 86
 	    #find_package(CxxTest REQUIRED)
83 87
     endif()
84 88
 endif()
@@ -115,4 +119,12 @@ if ( LEMMA_MATIO_SUPPORT )
115 119
 	)
116 120
 endif()
117 121
 
122
+#ExternalProject_Add (Lemma_SB
123
+#  DEPENDS ${DEPENDENCIES}
124
+#  SOURCE_DIR ${PROJECT_SOURCE_DIR}
125
+#  CMAKE_ARGS -DUSE_SUPERBUILD=OFF ${EXTRA_CMAKE_ARGS}
126
+#  INSTALL_COMMAND ""
127
+#  BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/blah)
128
+
129
+
118 130
 # vim: set tabstop=4 shiftwidth=4 expandtab: 

+ 36
- 29
CMakeLists.txt Dosyayı Görüntüle

@@ -1,10 +1,16 @@
1 1
 cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
2 2
 
3
+# Bug in CMake on Linux, but Linux, Mac, and Win all support shared libraries, no harm in this, 
4
+# but remove when warning no longer shows.
5
+# Related to calling find_package before a project is created... 
6
+# https://cmake.org/Bug/view.php?id=15999 
7
+SET_PROPERTY(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE)
8
+
3 9
 ####################################################################################################
4 10
 # Lemma versioning, set Major, minor, and patch here                                               #
5 11
 set(LEMMA_VERSION_MAJOR "0")                                                                       #
6 12
 set(LEMMA_VERSION_MINOR "2")                                                                       #
7
-set(LEMMA_VERSION_PATCH "1")                                                                       #
13
+set(LEMMA_VERSION_PATCH "2")                                                                       #
8 14
 set(LEMMA_VERSION "\"${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}\"")      #
9 15
 set(LEMMA_VERSION_NOQUOTES "${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}") #
10 16
 ####################################################################################################
@@ -23,9 +29,14 @@ option ( LEMMA_BUILD_EXAMPLES       "Compile example Lemma applications" OFF )
23 29
 option ( LEMMA_USE_OPENMP           "Use OpenMP in Lemma" OFF )
24 30
 option ( LEMMA_BUILD_DOCUMENTATION  "Build Doxygen man pages" OFF )
25 31
 
32
+option (LEMMA_VTK6_SUPPORT "VTK 6.x library for visualisation and grids" OFF)
33
+option (LEMMA_VTK7_SUPPORT "VTK 7.x library for visualisation and grids" OFF)
34
+option (LEMMA_VTK8_SUPPORT "VTK 8.x library for visualisation and grids" OFF)
35
+
26 36
 ## Hard Dependencies
27
-find_package (Eigen3 3.3  NO_MODULE QUIET)   # Matrix/Vector & Math
28
-find_package (yaml-cpp 0.6 QUIET)            # Serialisation of classes 
37
+#set(Eigen3_DIR  ${CMAKE_INSTALL_PREFIX} )
38
+find_package (Eigen3 3.3 QUIET)     # Matrix/Vector & Math
39
+find_package (yaml-cpp 0.6 QUIET )  # Serialisation of classes 
29 40
 
30 41
 INCLUDE_DIRECTORIES(${YAML_CPP_INCLUDE_DIR})
31 42
 
@@ -35,20 +46,17 @@ endif()
35 46
 
36 47
 ## Optional Dependencies
37 48
 if (LEMMA_ENABLE_TESTING)
38
-    message (STATUS "LEMMA_ENABLE_TESTING is set" )
39
-    #find_package (CxxTest QUIET)            # Unit testing
40
-    if (EXISTS  "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/cxxtest")
41
-	    set (CXXTEST_INCLUDE_DIR  "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/" CACHE PATH "" FORCE)
49
+    if (EXISTS "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/README")
50
+	    set (CXXTEST_INCLUDE_DIR  "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/"  CACHE PATH "" FORCE )
42 51
     else()
43
-	    set (CXXTEST_INCLUDE_DIR  "CXXTEST_INCLUDE_DIR-NOTFOUND" CACHE PATH "" FORCE)
52
+	    set (CXXTEST_INCLUDE_DIR  "CXXTEST_INCLUDE_DIR-NOTFOUND"  CACHE PATH "" FORCE )
44 53
     endif()
45
-    if (EXISTS "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/bin/cxxtestgen")
46
-	    set (CXXTEST_PYTHON_TESTGEN_EXECUTABLE "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/bin/cxxtestgen" CACHE PATH "" FORCE) 
54
+    if (EXISTS  "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/bin/cxxtestgen")
55
+	    set (CXXTEST_PYTHON_TESTGEN_EXECUTABLE "${CMAKE_CURRENT_BINARY_DIR}/external/CxxTest/src/CxxTest/bin/cxxtestgen" CACHE PATH "" FORCE )
47 56
     else()
48
-	    set (CXXTEST_PYTHON_TESTGEN_EXECUTABLE "CXXTEST_PYTHON_TESTGEN_EXECUTABLE-NOTFOUND" CACHE PATH "" FORCE) 
49
-    endif ()
50
-    find_package (CxxTest)            # Unit testing 
51
-    message (STATUS "CXXTEST_FOUND ${CxxTest_FOUND}" )
57
+	    set (CXXTEST_PYTHON_TESTGEN_EXECUTABLE "CXXTEST_PYTHON_TESTGEN_EXECUTABLE-NOTFOUND" CACHE PATH "" FORCE )
58
+    endif()
59
+    find_package (CxxTest QUIET)   # Unit testing 
52 60
 endif()
53 61
 
54 62
 #######################################################################
@@ -71,13 +79,9 @@ if ( NOT Eigen3_FOUND OR
71 79
   	# execute the superbuild (this script will be invoked again without the
72 80
   	# USE_SUPERBUILD option this time)
73 81
   	include (CMake/SuperBuild.cmake)
74
-
75
-    #add_dependencies(SUPERBUILD CxxTest) 
76
-
77 82
   	return()                      # stop processing this file further
78 83
 else()
79 84
 	#project (Blah)                # <-- YOUR PROJECT NAME HERE
80
-	message( STATUS "CXX test Dir${CXXTEST_DIR}" )
81 85
 	message( STATUS "Everything was found, happy Lemma-ing" )
82 86
 endif()
83 87
 
@@ -91,6 +95,13 @@ set(CMAKE_MACOSX_RPATH 1)
91 95
 
92 96
 project (Lemma CXX)
93 97
 
98
+# Disallow in-source build
99
+if ("${Lemma_SOURCE_DIR}"  STREQUAL "${Lemma_BINARY_DIR}")
100
+  message(FATAL_ERROR
101
+    "Lemma requires an out of source Build. "
102
+    "Please create a separate binary directory and run CMake there.")
103
+endif()
104
+
94 105
 ##############################
95 106
 # required external programs # for downloading packages
96 107
 ##############################
@@ -120,7 +131,7 @@ endif(NOT CMAKE_BUILD_TYPE)
120 131
 ###################
121 132
 
122 133
 # We don't build VTK, it is too heavy.
123
-option (LEMMA_VTK6_SUPPORT "VTK library for visualisation and grids" OFF)
134
+
124 135
 if ( LEMMA_VTK6_SUPPORT ) 
125 136
 	#find_package(VTK 6 REQUIRED NO_MODULE)
126 137
 	find_package(VTK 6.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources 
@@ -134,7 +145,7 @@ if ( LEMMA_VTK6_SUPPORT )
134 145
 	#include_directories ("${PROJECT_SOURCE_DIR}/Matplot_vtk")
135 146
 endif()
136 147
 
137
-option (LEMMA_VTK7_SUPPORT "VTK library for visualisation and grids" OFF)
148
+
138 149
 if ( LEMMA_VTK7_SUPPORT ) 
139 150
 	#find_package(VTK 7 REQUIRED NO_MODULE)
140 151
 	find_package(VTK 7.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources 
@@ -164,7 +175,7 @@ if ( LEMMA_VTK7_SUPPORT )
164 175
 	endif()
165 176
 endif()
166 177
 
167
-option (LEMMA_VTK8_SUPPORT "VTK library for visualisation and grids" OFF)
178
+
168 179
 if ( LEMMA_VTK8_SUPPORT ) 
169 180
 	find_package(VTK 8.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources 
170 181
 			vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkInteractionStyle 
@@ -231,14 +242,10 @@ endif()
231 242
 SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
232 243
 
233 244
 if (LEMMA_USE_OPENMP)
234
-    find_package(OpenMP)
235
-    if (OPENMP_FOUND)
236
-        set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
237
-        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
238
-        set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
239
-    else()
240
-	message (FATAL ERROR "OpenMP cannot be found, but was specified!")
241
-    endif()
245
+    find_package(OpenMP REQUIRED)
246
+    set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
247
+    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
248
+    set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
242 249
 endif()
243 250
 
244 251
 configure_file (

Loading…
İptal
Kaydet