Browse Source

Cross-compiler works with gcc targeting win-64

submodule
T-bone 6 years ago
parent
commit
c4d4232ce7
3 changed files with 54 additions and 32 deletions
  1. 32
    0
      CMake/Mingw-Cross.cmake
  2. 20
    31
      CMakeLists.txt
  3. 2
    1
      Modules/LemmaCore/CMakeLists.txt

+ 32
- 0
CMake/Mingw-Cross.cmake View File

1
+# Sample toolchain file for building for Windows from an Ubuntu Linux system.
2
+#
3
+# Typical usage:
4
+#    *) install cross compiler: `sudo apt-get install mingw-w64 g++-mingw-w64`
5
+#    *) cd build
6
+#    *) cmake -DCMAKE_TOOLCHAIN_FILE=~/Mingw-Cross.cmake ..
7
+
8
+set(CMAKE_SYSTEM_NAME Windows)
9
+set(CMAKE_SYSTEM Windows)
10
+set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
11
+
12
+SET(CMAKE_CROSSCOMPILING 1)
13
+
14
+# cross compilers to use for C and C++
15
+set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
16
+set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
17
+set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
18
+
19
+# target environment on the build host system
20
+#   set 1st to dir with the cross compiler's C/C++ headers/libs
21
+set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
22
+
23
+# modify default behavior of FIND_XXX() commands to
24
+# search for headers/libs in the target environment and
25
+# search for programs in the build host environment
26
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
27
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
28
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
29
+set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
30
+
31
+set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
32
+set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")

+ 20
- 31
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
+set(LEMMA_VERSION_MAJOR "0")
4
+set(LEMMA_VERSION_MINOR "2")
5
+set(LEMMA_VERSION_PATCH "1")
6
+set(LEMMA_VERSION "\"${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}\"")
7
+set(LEMMA_VERSION_NOQUOTES "${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}")
8
+
3
 # Mac OSX RPATH is weird 
9
 # Mac OSX RPATH is weird 
4
 # enable @rpath in the install name for any shared library being built
10
 # enable @rpath in the install name for any shared library being built
5
 # note: it is planned that a future version of CMake will enable this by default
11
 # note: it is planned that a future version of CMake will enable this by default
10
 
16
 
11
 project (Lemma CXX)
17
 project (Lemma CXX)
12
 
18
 
13
-# required external programs (for runtime of nix, not buildtime)
19
+##############################
20
+# required external programs # for downloading packages
21
+##############################
14
 FIND_PROGRAM(HAVEGIT git
22
 FIND_PROGRAM(HAVEGIT git
15
   PATHS /usr/bin/ /bin ENV PATH NO_DEFAULT_PATH
23
   PATHS /usr/bin/ /bin ENV PATH NO_DEFAULT_PATH
16
 )
24
 )
38
 include(ExternalProject)
46
 include(ExternalProject)
39
 ##########################################################################################
47
 ##########################################################################################
40
 # Eigen, this header-library is used extensively for linear algebra, matrices, and arrays
48
 # Eigen, this header-library is used extensively for linear algebra, matrices, and arrays
41
-# Mercurial (hg) repo pull, Would it be better to just download latest stable?
42
-FIND_PROGRAM( HAVEHG hg
43
-  PATHS /usr/bin/ /bin ENV PATH NO_DEFAULT_PATH
44
-)
45
-if (HAVEHG)
46
-	ExternalProject_Add(EIGEN
47
-	HG_REPOSITORY  "https://bitbucket.org/eigen/eigen/"
49
+# Eigen now has an official mirror on GitHub, so Mercurial is no longer a requirement! 
50
+ExternalProject_Add(EIGEN
51
+	GIT_REPOSITORY "https://github.com/eigenteam/eigen-git-mirror.git"
48
 	UPDATE_COMMAND ""
52
 	UPDATE_COMMAND ""
49
-	HG_TAG "3.3.2" #"default"
53
+	GIT_TAG "3.3.3" #"default"
50
    	PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
54
    	PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
51
    	CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
55
    	CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
52
 )
56
 )
53
-ELSE()
54
-	# Use Stable Eigen instead
55
-	ExternalProject_Add(EIGEN
56
-	#URL "http://bitbucket.org/eigen/eigen/get/default.tar.gz" # tip from repo
57
-    URL "http://bitbucket.org/eigen/eigen/get/3.3.2.tar.gz"
58
-   	PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
59
-   	CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}
60
-	)	
61
-ENDIF()
62
 include_directories ("${CMAKE_INSTALL_PREFIX}/include/eigen3")
57
 include_directories ("${CMAKE_INSTALL_PREFIX}/include/eigen3")
63
 
58
 
64
 #############################################################################################
59
 #############################################################################################
65
 # Yaml-cpp, this library is used extensively for serialisation of classes (class persistence) 
60
 # Yaml-cpp, this library is used extensively for serialisation of classes (class persistence) 
66
-find_package(yaml-cpp)
61
+#find_package(yaml-cpp)
67
 if (yaml-cpp_FOUND)
62
 if (yaml-cpp_FOUND)
68
     message( STATUS "YAML-CPP FOUND ${yaml-cpp_FOUND}" )
63
     message( STATUS "YAML-CPP FOUND ${yaml-cpp_FOUND}" )
69
     message( STATUS "YAML-CPP LIBRARIES ${YAML_CPP_LIBRARIES}" )
64
     message( STATUS "YAML-CPP LIBRARIES ${YAML_CPP_LIBRARIES}" )
72
     message( STATUS "YAML-CPP WAS NOT FOUND" )
67
     message( STATUS "YAML-CPP WAS NOT FOUND" )
73
 	ExternalProject_Add(YAML_CPP
68
 	ExternalProject_Add(YAML_CPP
74
 		GIT_REPOSITORY  "https://github.com/jbeder/yaml-cpp.git"
69
 		GIT_REPOSITORY  "https://github.com/jbeder/yaml-cpp.git"
75
-		GIT_TAG   "master" #"release-0.5.3" #"master"
70
+		GIT_TAG   "yaml-cpp-0.6.1" # "master" 
76
 		UPDATE_COMMAND ""
71
 		UPDATE_COMMAND ""
77
 		PATCH_COMMAND ""
72
 		PATCH_COMMAND ""
78
     	PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/yaml-cpp
73
     	PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/yaml-cpp
79
-    	CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} /
80
-        	       -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} /
81
-    	           -DYAML_CPP_BUILD_TESTS=OFF 
74
+    	CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} 
75
+                   -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} 
76
+                   -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} 
77
+    	           -DYAML_CPP_BUILD_TESTS=OFF
82
 	)	
78
 	)	
79
+	find_package(yaml-cpp)
83
 endif()
80
 endif()
84
-#add_compile_options(-DHAVE_YAMLCPP) 
85
 
81
 
86
 # CxxTest 
82
 # CxxTest 
87
 find_package(CxxTest) 
83
 find_package(CxxTest) 
189
 
185
 
190
 option (LEMMA_VTK8_SUPPORT "VTK library for visualisation and grids" OFF)
186
 option (LEMMA_VTK8_SUPPORT "VTK library for visualisation and grids" OFF)
191
 if ( LEMMA_VTK8_SUPPORT ) 
187
 if ( LEMMA_VTK8_SUPPORT ) 
192
-	#find_package(VTK 7 REQUIRED NO_MODULE)
193
 	find_package(VTK 8.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources 
188
 	find_package(VTK 8.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources 
194
 			vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkInteractionStyle 
189
 			vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkInteractionStyle 
195
 			vtkRenderingAnnotation vtkFiltersHybrid vtkFiltersModeling vtkRenderingVolumeOpenGL2 NO_MODULE)
190
 			vtkRenderingAnnotation vtkFiltersHybrid vtkFiltersModeling vtkRenderingVolumeOpenGL2 NO_MODULE)
268
     endif()
263
     endif()
269
 endif()
264
 endif()
270
 
265
 
271
-set(LEMMA_VERSION_MAJOR "0")
272
-set(LEMMA_VERSION_MINOR "2")
273
-set(LEMMA_VERSION_PATCH "0")
274
-set(LEMMA_VERSION "\"${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}\"")
275
-set(LEMMA_VERSION_NOQUOTES "${LEMMA_VERSION_MAJOR}.${LEMMA_VERSION_MINOR}.${LEMMA_VERSION_PATCH}")
276
-
277
 configure_file (
266
 configure_file (
278
 	"${PROJECT_SOURCE_DIR}/config/LemmaConfig.h.in"
267
 	"${PROJECT_SOURCE_DIR}/config/LemmaConfig.h.in"
279
 	"${PROJECT_BINARY_DIR}/include/LemmaConfig.h"
268
 	"${PROJECT_BINARY_DIR}/include/LemmaConfig.h"

+ 2
- 1
Modules/LemmaCore/CMakeLists.txt View File

11
 )
11
 )
12
 
12
 
13
 # External project dependencies 
13
 # External project dependencies 
14
-#add_dependencies(lemmacore YAML_CPP)
14
+add_dependencies(lemmacore YAML_CPP)
15
 
15
 
16
 if (LEMMA_TINYXML_SUPPORT)
16
 if (LEMMA_TINYXML_SUPPORT)
17
 	add_dependencies(lemmacore TINYXML2)
17
 	add_dependencies(lemmacore TINYXML2)
23
 # Linking
23
 # Linking
24
 if ( LEMMA_VTK6_SUPPORT OR LEMMA_VTK7_SUPPORT OR LEMMA_VTK8_SUPPORT ) 
24
 if ( LEMMA_VTK6_SUPPORT OR LEMMA_VTK7_SUPPORT OR LEMMA_VTK8_SUPPORT ) 
25
 	target_link_libraries(lemmacore ${VTK_LIBRARIES})
25
 	target_link_libraries(lemmacore ${VTK_LIBRARIES})
26
+#	target_link_libraries(lemmacore "yaml-cpp")
26
 #	target_link_libraries(lemmacore "matplot")
27
 #	target_link_libraries(lemmacore "matplot")
27
 endif()
28
 endif()
28
 
29
 

Loading…
Cancel
Save