@@ -86,14 +86,40 @@ set(NETWORK "netlrts" CACHE STRING "Target network layer, can be one of mpi,mult
8686set (TARGET "charm++" CACHE STRING "Target build type, can be one of charm++,AMPI,LIBS,charm4py,ChaNGa,everylb,all-test" )
8787set (ARCH "" CACHE STRING "Target architecture, can be one of i386,x86_64,arm7,arm8,ppc64le" ) # By default, detect arch we are running on.
8888
89- if (NOT ARCH STREQUAL CMAKE_HOST_SYSTEM_PROCESSOR )
90- if (ARCH STREQUAL "i386" AND CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64" )
91- message (WARNING "Attempting to cross-compile from ${CMAKE_HOST_SYSTEM_PROCESSOR} to ${ARCH} . This is only supported for x86_64 -> i386 currently." )
89+ function (charm_determine_arch output input )
90+ if (input STREQUAL "x86_64" OR input STREQUAL "AMD64" )
91+ set (retval "x86_64" )
92+ elseif (input STREQUAL "i386" OR input STREQUAL "i686" )
93+ set (retval "i386" )
94+ elseif (input STREQUAL "powerpc" OR input MATCHES "^ppc" )
95+ set (retval "ppc64le" )
96+ elseif (input MATCHES "armv6" OR input MATCHES "armv7" )
97+ set (retval "arm7" )
98+ elseif (input MATCHES "aarch64" OR input MATCHES "arm64" )
99+ set (retval "arm8" )
100+ else ()
101+ set (retval ${input} )
102+ endif ()
103+
104+ set (${output} ${retval} PARENT_SCOPE)
105+ endfunction ()
106+
107+ if (ARCH)
108+ set (CHARM_CPU ${ARCH} )
109+ else ()
110+ charm_determine_arch(CHARM_CPU ${CMAKE_SYSTEM_PROCESSOR} )
111+ endif ()
112+
113+ charm_determine_arch(CHARM_HOST_CPU ${CMAKE_HOST_SYSTEM_PROCESSOR} )
114+
115+ if (NOT CHARM_CPU STREQUAL CHARM_HOST_CPU)
116+ if (CHARM_CPU STREQUAL "i386" AND CHARM_HOST_CPU STREQUAL "x86_64" )
117+ message (STATUS "Attempting to cross-compile from ${CHARM_HOST_CPU} to ${CHARM_CPU} ." )
92118 set (CMAKE_C_FLAGS -m32)
93119 set (CMAKE_CXX_FLAGS -m32)
94120 set (CMAKE_Fortran_FLAGS -m32)
95121 else ()
96- message (WARNING "Cross-compiling from ${CMAKE_HOST_SYSTEM_PROCESSOR } to ${ARCH } is not supported currently." )
122+ message (WARNING "Cross-compiling from ${CHARM_HOST_CPU } to ${CHARM_CPU } is not supported currently." )
97123 endif ()
98124endif ()
99125
@@ -341,24 +367,11 @@ else()
341367endif ()
342368
343369set (CMK_POWER7 0)
344- if (ARCH)
345- set (CHARM_CPU ${ARCH} )
346- elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64" )
347- set (CHARM_CPU "x86_64" )
348- elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "i386" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "i686" )
349- set (CHARM_CPU "i386" )
350- elseif (CMAKE_SYSTEM_PROCESSOR STREQUAL "powerpc" OR CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc" )
351- set (CHARM_CPU "ppc64le" )
370+ if (CHARM_CPU STREQUAL "ppc64le" )
352371 execute_process (COMMAND grep f Makefile RESULT_VARIABLE isppc7 OUTPUT_QUIET ERROR_QUIET)
353372 if (${isppc7} )
354373 set (CMK_POWER7 1)
355374 endif ()
356- elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "armv6" OR CMAKE_SYSTEM_PROCESSOR MATCHES "armv7" )
357- set (CHARM_CPU "arm7" )
358- elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" OR CMAKE_SYSTEM_PROCESSOR MATCHES "arm64" )
359- set (CHARM_CPU "arm8" )
360- else ()
361- message (FATAL_ERROR "Unsupported CPU ${CMAKE_SYSTEM_PROCESSOR} ." )
362375endif ()
363376
364377# Adjust version number so it can be tested by numerical comparisons, e.g. 6.10.1 -> 61001:
@@ -566,6 +579,10 @@ set(VDIR ${CHARM_PLATFORM})
566579set (CMK_VDIR ${VDIR} )
567580set (CMK_GDIR ${GDIR} )
568581
582+ if (NOT EXISTS ${CMAKE_SOURCE_DIR} /src/arch/${VDIR} /)
583+ message (FATAL_ERROR "Unsupported platform ${VDIR} ." )
584+ endif ()
585+
569586configure_file (src/arch/common/cc-bluegene.sh include / COPYONLY )
570587configure_file (src/arch/common/cc-clang.sh include / COPYONLY )
571588configure_file (src/arch/common/cc-clang.h include / COPYONLY )
0 commit comments