Improvements to previous commit (cross-compile).
authorSacha Refshauge <xsacha@gmail.com>
Sun, 20 Aug 2017 12:50:31 +0000 (22:50 +1000)
committerSacha Refshauge <xsacha@gmail.com>
Sun, 20 Aug 2017 12:50:31 +0000 (22:50 +1000)
Fix typos and bad if statements discovered in 0.2.20.

cmake/f_check.cmake
cmake/prebuild.cmake
cmake/system.cmake
kernel/CMakeLists.txt

index 6eee027..4848553 100644 (file)
@@ -34,11 +34,7 @@ else()
 endif()
 
 if (NOT ONLY_CBLAS)
-  # N.B. f_check is not cross-platform, so instead try to use CMake variables
   # run f_check (appends to TARGET files)
-#  message(STATUS "Running f_check...")
-#  execute_process(COMMAND perl f_check ${TARGET_MAKE} ${TARGET_CONF} ${CMAKE_Fortran_COMPILER}
-#    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
 
   # TODO: detect whether underscore needed, set #defines and BU appropriately - use try_compile
   # TODO: set FEXTRALIB flags a la f_check?
index a1b3e0f..6ecb9f0 100644 (file)
@@ -42,23 +42,12 @@ if (DEFINED CPUIDEMU)
   set(EXFLAGS "-DCPUIDEMU -DVENDOR=99")
 endif ()
 
-if(CMAKE_CROSSCOMPILING AND NOT DEFINED TARGET_CORE)
-  # Detect target without running getarch
-  if(AARCH64)
-    set(TARGET_CORE "ARMV8")
-  else()
-    message(FATAL_ERROR "When cross compiling, a TARGET_CORE is required.")
-  endif()
-endif()
-
-if (DEFINED TARGET_CORE)
+if (BUILD_KERNEL)
   # set the C flags for just this file
   set(GETARCH2_FLAGS "-DBUILD_KERNEL")
-  set(TARGET_MAKE "Makefile_kernel.conf")
   set(TARGET_CONF "config_kernel.h")
   set(TARGET_CONF_DIR ${PROJECT_BINARY_DIR}/kernel_config/${TARGET_CORE})
 else()
-  set(TARGET_MAKE "Makefile.conf")
   set(TARGET_CONF "config.h")
   set(TARGET_CONF_DIR ${PROJECT_BINARY_DIR})
 endif ()
@@ -70,16 +59,26 @@ if (NOT NOFORTRAN)
   include("${PROJECT_SOURCE_DIR}/cmake/f_check.cmake")
 endif ()
 
+# This check requires c_check for arch but it should probably be done earlier
+if(CMAKE_CROSSCOMPILING AND NOT DEFINED CORE)
+  # Detect target without running getarch
+  if(ARM64)
+    set(CORE "ARMV8")
+  else()
+    message(FATAL_ERROR "When cross compiling, a CORE is required.")
+  endif()
+endif()
+
 # Cannot run getarch on target if we are cross-compiling
-if (CMAKE_CROSSCOMPILING)
+if (DEFINED CORE AND CMAKE_CROSSCOMPILING)
   # Write to config as getarch would
 
   # TODO: Set up defines that getarch sets up based on every other target
   # Perhaps this should be inside a different file as it grows larger
   file(APPEND ${TARGET_CONF_TEMP}
-    "#define ${TARGET_CORE}\n"
-    "#define CHAR_CORENAME \"${TARGET_CORE}\"\n")
-  if ("${TARGET_CORE}" STREQUAL "ARMV8")
+    "#define ${CORE}\n"
+    "#define CHAR_CORENAME \"${CORE}\"\n")
+  if ("${CORE}" STREQUAL "ARMV8")
     file(APPEND ${TARGET_CONF_TEMP}
       "#define L1_DATA_SIZE\t32768\n"
       "#define L1_DATA_LINESIZE\t64\n"
@@ -90,7 +89,7 @@ if (CMAKE_CROSSCOMPILING)
       "#define L2_ASSOCIATIVE\t32\n")
     set(SGEMM_UNROLL_M 4)
     set(SGEMM_UNROLL_N 4)
-  elseif ("${TARGET_CORE}" STREQUAL "CORTEXA57")
+  elseif ("${CORE}" STREQUAL "CORTEXA57")
     file(APPEND ${TARGET_CONF_TEMP}
       "#define L1_CODE_SIZE\t49152\n"
       "#define L1_CODE_LINESIZE\t64\n"
@@ -107,14 +106,14 @@ if (CMAKE_CROSSCOMPILING)
       "#define HAVE_VFPV3\n"
       "#define HAVE_VFP\n"
       "#define HAVE_NEON\n")
-    set(SGEMM_DEFAULT_UNROLL_M 16)
-    set(SGEMM_DEFAULT_UNROLL_N 4)
-    set(DGEMM_DEFAULT_UNROLL_M 8)
-    set(DGEMM_DEFAULT_UNROLL_N 4)
-    set(CGEMM_DEFAULT_UNROLL_M 8)
-    set(CGEMM_DEFAULT_UNROLL_N 4)
-    set(ZGEMM_DEFAULT_UNROLL_M 8)
-    set(ZGEMM_DEFAULT_UNROLL_N 4)
+    set(SGEMM_UNROLL_M 16)
+    set(SGEMM_UNROLL_N 4)
+    set(DGEMM_UNROLL_M 8)
+    set(DGEMM_UNROLL_N 4)
+    set(CGEMM_UNROLL_M 8)
+    set(CGEMM_UNROLL_N 4)
+    set(ZGEMM_UNROLL_M 8)
+    set(ZGEMM_UNROLL_N 4)
   endif()
 
   # Or should this actually be NUM_CORES?
@@ -134,105 +133,101 @@ if (CMAKE_CROSSCOMPILING)
   file(APPEND ${TARGET_CONF_TEMP}
     "#define GEMM_MULTITHREAD_THRESHOLD\t${GEMM_MULTITHREAD_THRESHOLD}\n")
   # Move to where gen_config_h would place it
-  file(RENAME ${TARGET_CONF_TEMP} "${PROJECT_BINARY_DIR}/config.h")  
-
-else()
-# compile getarch
-set(GETARCH_SRC
-  ${PROJECT_SOURCE_DIR}/getarch.c
-  ${CPUIDEMO}
-)
-
-if ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
-  #Use generic for MSVC now
-  message("MSVC")
-  set(GETARCH_FLAGS ${GETARCH_FLAGS} -DFORCE_GENERIC)
-else()
-  list(APPEND GETARCH_SRC ${PROJECT_SOURCE_DIR}/cpuid.S)
-endif ()
-
-if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
-  # disable WindowsStore strict CRT checks
-  set(GETARCH_FLAGS ${GETARCH_FLAGS} -D_CRT_SECURE_NO_WARNINGS)
-endif ()
+  file(RENAME ${TARGET_CONF_TEMP} "${TARGET_CONF_DIR}/${TARGET_CONF}")  
 
-set(GETARCH_DIR "${PROJECT_BINARY_DIR}/getarch_build")
-set(GETARCH_BIN "getarch${CMAKE_EXECUTABLE_SUFFIX}")
-file(MAKE_DIRECTORY ${GETARCH_DIR})
-configure_file(${TARGET_CONF_TEMP} ${GETARCH_DIR}/${TARGET_CONF} COPYONLY)
-if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
-  try_compile(GETARCH_RESULT ${GETARCH_DIR}
-    SOURCES ${GETARCH_SRC}
-    COMPILE_DEFINITIONS ${EXFLAGS} ${GETARCH_FLAGS} -I${GETARCH_DIR} -I${PROJECT_SOURCE_DIR} -I${PROJECT_BINARY_DIR}
-    OUTPUT_VARIABLE GETARCH_LOG
-    COPY_FILE ${PROJECT_BINARY_DIR}/${GETARCH_BIN}
+else(NOT CMAKE_CROSSCOMPILING)
+  # compile getarch
+  set(GETARCH_SRC
+    ${PROJECT_SOURCE_DIR}/getarch.c
+    ${CPUIDEMU}
   )
 
-  if (NOT ${GETARCH_RESULT})
-    MESSAGE(FATAL_ERROR "Compiling getarch failed ${GETARCH_LOG}")
+  if ("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
+    #Use generic for MSVC now
+    message("MSVC")
+    set(GETARCH_FLAGS ${GETARCH_FLAGS} -DFORCE_GENERIC)
+  else()
+    list(APPEND GETARCH_SRC ${PROJECT_SOURCE_DIR}/cpuid.S)
   endif ()
-endif ()
-message(STATUS "Running getarch")
-
-# use the cmake binary w/ the -E param to run a shell command in a cross-platform way
-execute_process(COMMAND ${PROJECT_BINARY_DIR}/${GETARCH_BIN} 0 OUTPUT_VARIABLE GETARCH_MAKE_OUT)
-execute_process(COMMAND ${PROJECT_BINARY_DIR}/${GETARCH_BIN} 1 OUTPUT_VARIABLE GETARCH_CONF_OUT)
-
-message(STATUS "GETARCH results:\n${GETARCH_MAKE_OUT}")
-
-# append config data from getarch to the TARGET file and read in CMake vars
-file(APPEND ${TARGET_CONF_TEMP} ${GETARCH_CONF_OUT})
-ParseGetArchVars(${GETARCH_MAKE_OUT})
-
-set(GETARCH2_DIR "${PROJECT_BINARY_DIR}/getarch2_build")
-set(GETARCH2_BIN "getarch_2nd${CMAKE_EXECUTABLE_SUFFIX}")
-file(MAKE_DIRECTORY ${GETARCH2_DIR})
-configure_file(${TARGET_CONF_TEMP} ${GETARCH2_DIR}/${TARGET_CONF} COPYONLY)
-if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
-  try_compile(GETARCH2_RESULT ${GETARCH2_DIR}
-    SOURCES ${PROJECT_SOURCE_DIR}/getarch_2nd.c
-    COMPILE_DEFINITIONS ${EXFLAGS} ${GETARCH_FLAGS} ${GETARCH2_FLAGS} -I${GETARCH2_DIR} -I${PROJECT_SOURCE_DIR} -I${PROJECT_BINARY_DIR}
-    OUTPUT_VARIABLE GETARCH2_LOG
-    COPY_FILE ${PROJECT_BINARY_DIR}/${GETARCH2_BIN}
-  )
 
-  if (NOT ${GETARCH2_RESULT})
-    MESSAGE(FATAL_ERROR "Compiling getarch_2nd failed ${GETARCH2_LOG}")
+  if ("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
+    # disable WindowsStore strict CRT checks
+    set(GETARCH_FLAGS ${GETARCH_FLAGS} -D_CRT_SECURE_NO_WARNINGS)
   endif ()
-endif ()
 
-# use the cmake binary w/ the -E param to run a shell command in a cross-platform way
-execute_process(COMMAND ${PROJECT_BINARY_DIR}/${GETARCH2_BIN} 0 OUTPUT_VARIABLE GETARCH2_MAKE_OUT)
-execute_process(COMMAND ${PROJECT_BINARY_DIR}/${GETARCH2_BIN} 1 OUTPUT_VARIABLE GETARCH2_CONF_OUT)
+  set(GETARCH_DIR "${PROJECT_BINARY_DIR}/getarch_build")
+  set(GETARCH_BIN "getarch${CMAKE_EXECUTABLE_SUFFIX}")
+  file(MAKE_DIRECTORY ${GETARCH_DIR})
+  configure_file(${TARGET_CONF_TEMP} ${GETARCH_DIR}/${TARGET_CONF} COPYONLY)
+  if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
+    try_compile(GETARCH_RESULT ${GETARCH_DIR}
+      SOURCES ${GETARCH_SRC}
+      COMPILE_DEFINITIONS ${EXFLAGS} ${GETARCH_FLAGS} -I${GETARCH_DIR} -I${PROJECT_SOURCE_DIR} -I${PROJECT_BINARY_DIR}
+      OUTPUT_VARIABLE GETARCH_LOG
+      COPY_FILE ${PROJECT_BINARY_DIR}/${GETARCH_BIN}
+    )
+  
+    if (NOT ${GETARCH_RESULT})
+      MESSAGE(FATAL_ERROR "Compiling getarch failed ${GETARCH_LOG}")
+    endif ()
+  endif ()
+  message(STATUS "Running getarch")
+
+  # use the cmake binary w/ the -E param to run a shell command in a cross-platform way
+  execute_process(COMMAND ${PROJECT_BINARY_DIR}/${GETARCH_BIN} 0 OUTPUT_VARIABLE GETARCH_MAKE_OUT)
+  execute_process(COMMAND ${PROJECT_BINARY_DIR}/${GETARCH_BIN} 1 OUTPUT_VARIABLE GETARCH_CONF_OUT)
+
+  message(STATUS "GETARCH results:\n${GETARCH_MAKE_OUT}")
+
+  # append config data from getarch to the TARGET file and read in CMake vars
+  file(APPEND ${TARGET_CONF_TEMP} ${GETARCH_CONF_OUT})
+  ParseGetArchVars(${GETARCH_MAKE_OUT})
+
+  set(GETARCH2_DIR "${PROJECT_BINARY_DIR}/getarch2_build")
+  set(GETARCH2_BIN "getarch_2nd${CMAKE_EXECUTABLE_SUFFIX}")
+  file(MAKE_DIRECTORY ${GETARCH2_DIR})
+  configure_file(${TARGET_CONF_TEMP} ${GETARCH2_DIR}/${TARGET_CONF} COPYONLY)
+  if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
+    try_compile(GETARCH2_RESULT ${GETARCH2_DIR}
+      SOURCES ${PROJECT_SOURCE_DIR}/getarch_2nd.c
+      COMPILE_DEFINITIONS ${EXFLAGS} ${GETARCH_FLAGS} ${GETARCH2_FLAGS} -I${GETARCH2_DIR} -I${PROJECT_SOURCE_DIR} -I${PROJECT_BINARY_DIR}
+      OUTPUT_VARIABLE GETARCH2_LOG
+      COPY_FILE ${PROJECT_BINARY_DIR}/${GETARCH2_BIN}
+    )
+
+    if (NOT ${GETARCH2_RESULT})
+      MESSAGE(FATAL_ERROR "Compiling getarch_2nd failed ${GETARCH2_LOG}")
+    endif ()
+  endif ()
 
-# append config data from getarch_2nd to the TARGET file and read in CMake vars
-file(APPEND ${TARGET_CONF_TEMP} ${GETARCH2_CONF_OUT})
+  # use the cmake binary w/ the -E param to run a shell command in a cross-platform way
+  execute_process(COMMAND ${PROJECT_BINARY_DIR}/${GETARCH2_BIN} 0 OUTPUT_VARIABLE GETARCH2_MAKE_OUT)
+  execute_process(COMMAND ${PROJECT_BINARY_DIR}/${GETARCH2_BIN} 1 OUTPUT_VARIABLE GETARCH2_CONF_OUT)
 
-if (${BUILD_KERNEL})
-    configure_file(${TARGET_CONF_TEMP} ${PROJECT_BINARY_DIR}/kernel_config/${TARGET_CORE}/${TARGET_CONF} COPYONLY)
-else ()
-    configure_file(${TARGET_CONF_TEMP} ${PROJECT_BINARY_DIR}/${TARGET_CONF} COPYONLY)
-endif ()
+  # append config data from getarch_2nd to the TARGET file and read in CMake vars
+  file(APPEND ${TARGET_CONF_TEMP} ${GETARCH2_CONF_OUT})
 
-ParseGetArchVars(${GETARCH2_MAKE_OUT})
+  configure_file(${TARGET_CONF_TEMP} ${TARGET_CONF_DIR}/${TARGET_CONF} COPYONLY)
 
-# compile get_config_h
-set(GEN_CONFIG_H_DIR "${PROJECT_BINARY_DIR}/genconfig_h_build")
-set(GEN_CONFIG_H_BIN "gen_config_h${CMAKE_EXECUTABLE_SUFFIX}")
-set(GEN_CONFIG_H_FLAGS "-DVERSION=\"${OpenBLAS_VERSION}\"")
-file(MAKE_DIRECTORY ${GEN_CONFIG_H_DIR})
+  ParseGetArchVars(${GETARCH2_MAKE_OUT})
 
-if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
-  try_compile(GEN_CONFIG_H_RESULT ${GEN_CONFIG_H_DIR}
-    SOURCES ${PROJECT_SOURCE_DIR}/gen_config_h.c
-    COMPILE_DEFINITIONS ${EXFLAGS} ${GETARCH_FLAGS} ${GEN_CONFIG_H_FLAGS} -I${PROJECT_SOURCE_DIR}
-    OUTPUT_VARIABLE GEN_CONFIG_H_LOG
-    COPY_FILE ${PROJECT_BINARY_DIR}/${GEN_CONFIG_H_BIN}
-  )
+  # compile get_config_h
+  set(GEN_CONFIG_H_DIR "${PROJECT_BINARY_DIR}/genconfig_h_build")
+  set(GEN_CONFIG_H_BIN "gen_config_h${CMAKE_EXECUTABLE_SUFFIX}")
+  set(GEN_CONFIG_H_FLAGS "-DVERSION=\"${OpenBLAS_VERSION}\"")
+  file(MAKE_DIRECTORY ${GEN_CONFIG_H_DIR})
 
-  if (NOT ${GEN_CONFIG_H_RESULT})
-    MESSAGE(FATAL_ERROR "Compiling gen_config_h failed ${GEN_CONFIG_H_LOG}")
-  endif ()
+  if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsStore")
+    try_compile(GEN_CONFIG_H_RESULT ${GEN_CONFIG_H_DIR}
+      SOURCES ${PROJECT_SOURCE_DIR}/gen_config_h.c
+      COMPILE_DEFINITIONS ${EXFLAGS} ${GETARCH_FLAGS} ${GEN_CONFIG_H_FLAGS} -I${PROJECT_SOURCE_DIR}
+      OUTPUT_VARIABLE GEN_CONFIG_H_LOG
+      COPY_FILE ${PROJECT_BINARY_DIR}/${GEN_CONFIG_H_BIN}
+    )
+
+    if (NOT ${GEN_CONFIG_H_RESULT})
+      MESSAGE(FATAL_ERROR "Compiling gen_config_h failed ${GEN_CONFIG_H_LOG}")
+    endif ()
 endif ()
 
-endif(CMAKE_CROSSCOMPILING)
+endif()
index 310b714..a665502 100644 (file)
@@ -4,17 +4,9 @@
 ##
 set(NETLIB_LAPACK_DIR "${PROJECT_SOURCE_DIR}/lapack-netlib")
 
-# TODO: Makefile.system detects Darwin (mac) and switches to clang here -hpa
-# http://stackoverflow.com/questions/714100/os-detecting-makefile
-
-# TODO: Makefile.system sets HOSTCC = $(CC) here if not already set -hpa
-
 # TARGET_CORE will override TARGET which is used in DYNAMIC_ARCH=1.
 if (DEFINED TARGET_CORE)
   set(TARGET ${TARGET_CORE})
-  if(NOT DEFINED CORE)
-    set(CORE ${TARGET_CORE})
-  endif()
 endif ()
 
 # Force fallbacks for 32bit
@@ -107,9 +99,6 @@ if (NOT DEFINED NEED_PIC)
   set(NEED_PIC 1)
 endif ()
 
-# TODO: I think CMake should be handling all this stuff -hpa
-unset(ARFLAGS)
-
 # OS dependent settings
 include("${PROJECT_SOURCE_DIR}/cmake/os.cmake")
 
index 2295829..9178ba7 100644 (file)
@@ -22,7 +22,7 @@ function (build_core TARGET_CORE KDIR TSUFFIX KERNEL_DEFINITIONS)
 
     if (${ADD_COMMONOBJS})
         if (${ARCH} STREQUAL "x86")
-        if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
+        if (NOT "${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC")
           GenerateNamedObjects("${KERNELDIR}/cpuid.S" "" "" false "" "" true)
         else()
           GenerateNamedObjects("${KERNELDIR}/cpuid_win.c" "" "" false "" "" true)