Browse Source

Clean up of build script for cxxtest

lagkey
T-bone 6 years ago
parent
commit
3836ac84ef
2 changed files with 54 additions and 35 deletions
  1. 18
    6
      CMake/SuperBuild.cmake
  2. 36
    29
      CMakeLists.txt

+ 18
- 6
CMake/SuperBuild.cmake View File

1
 include(ExternalProject)
1
 include(ExternalProject)
2
 
2
 
3
-if (eigen3_FOUND)
3
+if (Eigen3_FOUND)
4
     message( STATUS "Eigen was found ${eigen_DIR}" )
4
     message( STATUS "Eigen was found ${eigen_DIR}" )
5
 else()
5
 else()
6
     message( STATUS "Eigen WAS NOT FOUND ${eigen_DIR}" )
6
     message( STATUS "Eigen WAS NOT FOUND ${eigen_DIR}" )
14
 		#BUILD_COMMAND     ""
14
 		#BUILD_COMMAND     ""
15
 		#INSTALL_COMMAND     ""
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
     # Are these necessary?
22
     # Are these necessary?
19
     #include_directories ("${CMAKE_INSTALL_PREFIX}/include/eigen3/")
23
     #include_directories ("${CMAKE_INSTALL_PREFIX}/include/eigen3/")
20
     #set (Eigen3_DIR  "${CMAKE_INSTALL_PREFIX}/include/eigen3" CACHE  PATH "" FORCE )
24
     #set (Eigen3_DIR  "${CMAKE_INSTALL_PREFIX}/include/eigen3" CACHE  PATH "" FORCE )
39
 		GIT_TAG   "yaml-cpp-0.6.1" # "master" 
43
 		GIT_TAG   "yaml-cpp-0.6.1" # "master" 
40
 		UPDATE_COMMAND ""
44
 		UPDATE_COMMAND ""
41
 		PATCH_COMMAND ""
45
 		PATCH_COMMAND ""
42
-		INSTALL_COMMAND ""
43
     	PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/yaml-cpp
46
     	PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/yaml-cpp
44
     	CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} 
47
     	CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} 
45
                    -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} 
48
                    -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} 
46
-                   -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 
47
     	           -DYAML_CPP_BUILD_TESTS=OFF
49
     	           -DYAML_CPP_BUILD_TESTS=OFF
50
+                   -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 
51
+		#INSTALL_COMMAND ""
48
 	)	
52
 	)	
53
+
49
     # is this necessary?
54
     # is this necessary?
50
 	#include_directories ("${CMAKE_INSTALL_PREFIX}/include/yaml-cpp")
55
 	#include_directories ("${CMAKE_INSTALL_PREFIX}/include/yaml-cpp")
51
 endif()
56
 endif()
77
 	    # The values "CACHE PATH "" FORCE" makes the GUI show the values of the local CxxTest, but this can cause issues 
82
 	    # The values "CACHE PATH "" FORCE" makes the GUI show the values of the local CxxTest, but this can cause issues 
78
 	    # with users wanting to specify their own path. However, the SuperBuild needs this, in theory you are only here 
83
 	    # with users wanting to specify their own path. However, the SuperBuild needs this, in theory you are only here 
79
         # because a usable CXXTEST was not already found on the machine, so likely this is sane to do 
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
 	    #find_package(CxxTest REQUIRED)
86
 	    #find_package(CxxTest REQUIRED)
83
     endif()
87
     endif()
84
 endif()
88
 endif()
115
 	)
119
 	)
116
 endif()
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
 # vim: set tabstop=4 shiftwidth=4 expandtab: 
130
 # vim: set tabstop=4 shiftwidth=4 expandtab: 

+ 36
- 29
CMakeLists.txt View File

1
 cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
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
 # Lemma versioning, set Major, minor, and patch here                                               #
10
 # Lemma versioning, set Major, minor, and patch here                                               #
5
 set(LEMMA_VERSION_MAJOR "0")                                                                       #
11
 set(LEMMA_VERSION_MAJOR "0")                                                                       #
6
 set(LEMMA_VERSION_MINOR "2")                                                                       #
12
 set(LEMMA_VERSION_MINOR "2")                                                                       #
7
-set(LEMMA_VERSION_PATCH "1")                                                                       #
13
+set(LEMMA_VERSION_PATCH "2")                                                                       #
8
 set(LEMMA_VERSION "\"${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}\"")      #
14
 set(LEMMA_VERSION "\"${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}\"")      #
9
 set(LEMMA_VERSION_NOQUOTES "${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}") #
15
 set(LEMMA_VERSION_NOQUOTES "${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}") #
10
 ####################################################################################################
16
 ####################################################################################################
23
 option ( LEMMA_USE_OPENMP           "Use OpenMP in Lemma" OFF )
29
 option ( LEMMA_USE_OPENMP           "Use OpenMP in Lemma" OFF )
24
 option ( LEMMA_BUILD_DOCUMENTATION  "Build Doxygen man pages" OFF )
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
 ## Hard Dependencies
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
 INCLUDE_DIRECTORIES(${YAML_CPP_INCLUDE_DIR})
41
 INCLUDE_DIRECTORIES(${YAML_CPP_INCLUDE_DIR})
31
 
42
 
35
 
46
 
36
 ## Optional Dependencies
47
 ## Optional Dependencies
37
 if (LEMMA_ENABLE_TESTING)
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
     else()
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
     endif()
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
     else()
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
 endif()
60
 endif()
53
 
61
 
54
 #######################################################################
62
 #######################################################################
71
   	# execute the superbuild (this script will be invoked again without the
79
   	# execute the superbuild (this script will be invoked again without the
72
   	# USE_SUPERBUILD option this time)
80
   	# USE_SUPERBUILD option this time)
73
   	include (CMake/SuperBuild.cmake)
81
   	include (CMake/SuperBuild.cmake)
74
-
75
-    #add_dependencies(SUPERBUILD CxxTest) 
76
-
77
   	return()                      # stop processing this file further
82
   	return()                      # stop processing this file further
78
 else()
83
 else()
79
 	#project (Blah)                # <-- YOUR PROJECT NAME HERE
84
 	#project (Blah)                # <-- YOUR PROJECT NAME HERE
80
-	message( STATUS "CXX test Dir${CXXTEST_DIR}" )
81
 	message( STATUS "Everything was found, happy Lemma-ing" )
85
 	message( STATUS "Everything was found, happy Lemma-ing" )
82
 endif()
86
 endif()
83
 
87
 
91
 
95
 
92
 project (Lemma CXX)
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
 # required external programs # for downloading packages
106
 # required external programs # for downloading packages
96
 ##############################
107
 ##############################
120
 ###################
131
 ###################
121
 
132
 
122
 # We don't build VTK, it is too heavy.
133
 # We don't build VTK, it is too heavy.
123
-option (LEMMA_VTK6_SUPPORT "VTK library for visualisation and grids" OFF)
134
+
124
 if ( LEMMA_VTK6_SUPPORT ) 
135
 if ( LEMMA_VTK6_SUPPORT ) 
125
 	#find_package(VTK 6 REQUIRED NO_MODULE)
136
 	#find_package(VTK 6 REQUIRED NO_MODULE)
126
 	find_package(VTK 6.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources 
137
 	find_package(VTK 6.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources 
134
 	#include_directories ("${PROJECT_SOURCE_DIR}/Matplot_vtk")
145
 	#include_directories ("${PROJECT_SOURCE_DIR}/Matplot_vtk")
135
 endif()
146
 endif()
136
 
147
 
137
-option (LEMMA_VTK7_SUPPORT "VTK library for visualisation and grids" OFF)
148
+
138
 if ( LEMMA_VTK7_SUPPORT ) 
149
 if ( LEMMA_VTK7_SUPPORT ) 
139
 	#find_package(VTK 7 REQUIRED NO_MODULE)
150
 	#find_package(VTK 7 REQUIRED NO_MODULE)
140
 	find_package(VTK 7.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources 
151
 	find_package(VTK 7.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources 
164
 	endif()
175
 	endif()
165
 endif()
176
 endif()
166
 
177
 
167
-option (LEMMA_VTK8_SUPPORT "VTK library for visualisation and grids" OFF)
178
+
168
 if ( LEMMA_VTK8_SUPPORT ) 
179
 if ( LEMMA_VTK8_SUPPORT ) 
169
 	find_package(VTK 8.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources 
180
 	find_package(VTK 8.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources 
170
 			vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkInteractionStyle 
181
 			vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkInteractionStyle 
231
 SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
242
 SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
232
 
243
 
233
 if (LEMMA_USE_OPENMP)
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
 endif()
249
 endif()
243
 
250
 
244
 configure_file (
251
 configure_file (

Loading…
Cancel
Save