Browse Source

Improved cross compiling using GNU tools for WIN64

lagkey
Trevor Irons 6 years ago
parent
commit
4f7a8512ab
2 changed files with 45 additions and 15 deletions
  1. 15
    7
      CMake/Mingw-Cross.cmake
  2. 30
    8
      CMakeLists.txt

+ 15
- 7
CMake/Mingw-Cross.cmake View File

@@ -9,7 +9,8 @@ set(CMAKE_SYSTEM_NAME Windows)
9 9
 set(CMAKE_SYSTEM Windows)
10 10
 set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
11 11
 
12
-SET(CMAKE_CROSSCOMPILING 1)
12
+option (CMAKE_CROSSCOMPILING "Target different arch than you are on" ON)
13
+SET(CMAKE_CROSSCOMPILING ON)
13 14
 
14 15
 # cross compilers to use for C and C++
15 16
 set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
@@ -23,10 +24,17 @@ set(CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
23 24
 # modify default behavior of FIND_XXX() commands to
24 25
 # search for headers/libs in the target environment and
25 26
 # 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)
27
+set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
28
+set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
29
+set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
30
+set( CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY )
30 31
 
31
-set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
32
-set(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
32
+set( CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "" )
33
+set( CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "" )
34
+
35
+#set_target_properties(icarus PROPERTIES LINK_SEARCH_START_STATIC 1)
36
+#set_target_properties(icarus PROPERTIES LINK_SEARCH_END_STATIC 1)
37
+#set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
38
+#Static Libs
39
+#Set Linker flags
40
+set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")

+ 30
- 8
CMakeLists.txt View File

@@ -33,10 +33,25 @@ option (LEMMA_VTK6_SUPPORT "VTK 6.x library for visualisation and grids" OFF)
33 33
 option (LEMMA_VTK7_SUPPORT "VTK 7.x library for visualisation and grids" OFF)
34 34
 option (LEMMA_VTK8_SUPPORT "VTK 8.x library for visualisation and grids" OFF)
35 35
 
36
-## Hard Dependencies
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 
36
+#option (CMAKE_CROSSCOMPILING "Target different arch than you are on" OFF)
37
+
38
+##########################################################################################
39
+## Only look for packages where we build them...this makes finding VTK a problem though! #
40
+########################################################################################## 
41
+if (CMAKE_CROSSCOMPILING)
42
+    message ( STATUS "Cross-compiling! Only searching in install directory for components." )
43
+    SET( CMAKE_FIND_ROOT_PATH ONLY ${CMAKE_INSTALL_PREFIX})
44
+    SET( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY  ONLY ) 
45
+    SET( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE  ONLY ) 
46
+    SET( CMAKE_FIND_ROOT_PATH_MODE_PACKAGE  ONLY )
47
+    UNSET( Eigen3_DIR CACHE ) 
48
+    UNSET( yaml-cpp_DIR CACHE ) 
49
+    find_package (Eigen3 3.3 )# QUIET)     # Matrix/Vector & Math
50
+    find_package (yaml-cpp 0.6 ) #QUIET )  # Serialisation of classes 
51
+endif()
52
+
53
+find_package (Eigen3 3.3 )# QUIET)     # Matrix/Vector & Math
54
+find_package (yaml-cpp 0.6 ) #QUIET )  # Serialisation of classes 
40 55
 
41 56
 INCLUDE_DIRECTORIES(${YAML_CPP_INCLUDE_DIR})
42 57
 
@@ -242,10 +257,17 @@ endif()
242 257
 SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
243 258
 
244 259
 if (LEMMA_USE_OPENMP)
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}")
260
+    if (CMAKE_CROSSCOMPILING)
261
+        set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp")
262
+        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
263
+        set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fopenmp")
264
+        # 
265
+    else()
266
+        find_package(OpenMP REQUIRED)
267
+        set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
268
+        set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
269
+        set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
270
+    endif()
249 271
 endif()
250 272
 
251 273
 configure_file (

Loading…
Cancel
Save