瀏覽代碼

Cross-compiler works with gcc targeting win-64

submodule
T-bone 6 年之前
父節點
當前提交
c4d4232ce7
共有 3 個文件被更改,包括 54 次插入32 次删除
  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 查看文件

@@ -0,0 +1,32 @@
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 查看文件

@@ -1,5 +1,11 @@
1 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 9
 # Mac OSX RPATH is weird 
4 10
 # enable @rpath in the install name for any shared library being built
5 11
 # note: it is planned that a future version of CMake will enable this by default
@@ -10,7 +16,9 @@ set(CMAKE_MACOSX_RPATH 1)
10 16
 
11 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 22
 FIND_PROGRAM(HAVEGIT git
15 23
   PATHS /usr/bin/ /bin ENV PATH NO_DEFAULT_PATH
16 24
 )
@@ -38,32 +46,19 @@ endif(NOT CMAKE_BUILD_TYPE)
38 46
 include(ExternalProject)
39 47
 ##########################################################################################
40 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 52
 	UPDATE_COMMAND ""
49
-	HG_TAG "3.3.2" #"default"
53
+	GIT_TAG "3.3.3" #"default"
50 54
    	PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external/eigen
51 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 57
 include_directories ("${CMAKE_INSTALL_PREFIX}/include/eigen3")
63 58
 
64 59
 #############################################################################################
65 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 62
 if (yaml-cpp_FOUND)
68 63
     message( STATUS "YAML-CPP FOUND ${yaml-cpp_FOUND}" )
69 64
     message( STATUS "YAML-CPP LIBRARIES ${YAML_CPP_LIBRARIES}" )
@@ -72,16 +67,17 @@ else()
72 67
     message( STATUS "YAML-CPP WAS NOT FOUND" )
73 68
 	ExternalProject_Add(YAML_CPP
74 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 71
 		UPDATE_COMMAND ""
77 72
 		PATCH_COMMAND ""
78 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 80
 endif()
84
-#add_compile_options(-DHAVE_YAMLCPP) 
85 81
 
86 82
 # CxxTest 
87 83
 find_package(CxxTest) 
@@ -189,7 +185,6 @@ endif()
189 185
 
190 186
 option (LEMMA_VTK8_SUPPORT "VTK library for visualisation and grids" OFF)
191 187
 if ( LEMMA_VTK8_SUPPORT ) 
192
-	#find_package(VTK 7 REQUIRED NO_MODULE)
193 188
 	find_package(VTK 8.0 COMPONENTS vtkCommonCore vtkRenderingCore vtkFiltersCore vtkFiltersSources 
194 189
 			vtkCommonDataModel vtkFiltersHyperTree vtkIOXML vtkIOImage vtkIOLegacy vtkInteractionStyle 
195 190
 			vtkRenderingAnnotation vtkFiltersHybrid vtkFiltersModeling vtkRenderingVolumeOpenGL2 NO_MODULE)
@@ -268,12 +263,6 @@ if (LEMMA_USE_OPENMP)
268 263
     endif()
269 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 266
 configure_file (
278 267
 	"${PROJECT_SOURCE_DIR}/config/LemmaConfig.h.in"
279 268
 	"${PROJECT_BINARY_DIR}/include/LemmaConfig.h"

+ 2
- 1
Modules/LemmaCore/CMakeLists.txt 查看文件

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

Loading…
取消
儲存