*.def
*.o
*.out
+*.tmp
lapack-3.1.1
lapack-3.1.1.tgz
lapack-3.4.1
# Install include files
set (GENCONFIG_BIN ${CMAKE_BINARY_DIR}/gen_config_h${CMAKE_EXECUTABLE_SUFFIX})
- ADD_CUSTOM_COMMAND(
- OUTPUT ${CMAKE_BINARY_DIR}/openblas_config.h
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/config.h
- COMMAND ${GENCONFIG_BIN} ${CMAKE_CURRENT_SOURCE_DIR}/config.h ${CMAKE_CURRENT_SOURCE_DIR}/openblas_config_template.h > ${CMAKE_BINARY_DIR}/openblas_config.h
- )
- ADD_CUSTOM_TARGET(genconfig
- ALL
- DEPENDS openblas_config.h
- )
- add_dependencies(genconfig ${OpenBLAS_LIBNAME})
+ execute_process(COMMAND ${GENCONFIG_BIN}
+ ${CMAKE_CURRENT_SOURCE_DIR}/config.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/openblas_config_template.h
+ OUTPUT_VARIABLE OPENBLAS_CONFIG_H_CONTENTS)
+
+ file(WRITE ${CMAKE_BINARY_DIR}/openblas_config.tmp "${OPENBLAS_CONFIG_H_CONTENTS}")
+ configure_file(${CMAKE_BINARY_DIR}/openblas_config.tmp ${CMAKE_BINARY_DIR}/openblas_config.h COPYONLY)
install (FILES ${CMAKE_BINARY_DIR}/openblas_config.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
message(STATUS "Generating f77blas.h in ${CMAKE_INSTALL_INCLUDEDIR}")
- ADD_CUSTOM_TARGET(genf77blas
- ALL
- COMMAND ${AWK} 'BEGIN{print \"\#ifndef OPENBLAS_F77BLAS_H\" \; print \"\#define OPENBLAS_F77BLAS_H\" \; print \"\#include \\"openblas_config.h\\" \"}; NF {print}; END{print \"\#endif\"}' ${CMAKE_CURRENT_SOURCE_DIR}/common_interface.h > ${CMAKE_BINARY_DIR}/f77blas.h
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/config.h
- )
- add_dependencies(genf77blas ${OpenBLAS_LIBNAME})
-
+ file(WRITE ${CMAKE_BINARY_DIR}/f77blas.tmp "")
+ file(APPEND ${CMAKE_BINARY_DIR}/f77blas.tmp "#ifndef OPENBLAS_F77BLAS_H\n#define OPENBLAS_F77BLAS_H\n#include \"openblas_config.h\"\n")
+ file(READ ${CMAKE_CURRENT_SOURCE_DIR}/common_interface.h COMMON_INTERFACE_H_CONTENTS)
+ file(APPEND ${CMAKE_BINARY_DIR}/f77blas.tmp "${COMMON_INTERFACE_H_CONTENTS}")
+ file(APPEND ${CMAKE_BINARY_DIR}/f77blas.tmp "#endif")
+ configure_file(${CMAKE_BINARY_DIR}/f77blas.tmp ${CMAKE_BINARY_DIR}/f77blas.h COPYONLY)
install (FILES ${CMAKE_BINARY_DIR}/f77blas.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
if(NOT NO_CBLAS)
message (STATUS "Generating cblas.h in ${CMAKE_INSTALL_INCLUDEDIR}")
- ADD_CUSTOM_TARGET(gencblas
- ALL
- COMMAND ${SED} 's/common/openblas_config/g' ${CMAKE_CURRENT_SOURCE_DIR}/cblas.h > "${CMAKE_BINARY_DIR}/cblas.tmp"
- COMMAND cp "${CMAKE_BINARY_DIR}/cblas.tmp" "${CMAKE_BINARY_DIR}/cblas.h"
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cblas.h
- )
- add_dependencies(gencblas ${OpenBLAS_LIBNAME})
-
+ file(READ ${CMAKE_CURRENT_SOURCE_DIR}/cblas.h CBLAS_H_CONTENTS)
+ string(REPLACE "common" "openblas_config" CBLAS_H_CONTENTS_NEW "${CBLAS_H_CONTENTS}")
+ file(WRITE ${CMAKE_BINARY_DIR}/cblas.tmp "${CBLAS_H_CONTENTS_NEW}")
+ configure_file(${CMAKE_BINARY_DIR}/cblas.tmp ${CMAKE_CURRENT_SOURCE_DIR}/cblas.h COPYONLY)
install (FILES ${CMAKE_BINARY_DIR}/cblas.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif()
install (FILES ${INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
ADD_CUSTOM_TARGET(genlapacke
- COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/lapack-netlib/LAPACKE/include/lapacke_mangling_with_flags.h.in "${CMAKE_BINARY_DIR}/lapacke_mangling.h"
+ COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/lapack-netlib/LAPACKE/include/lapacke_mangling_with_flags.h.in "${CMAKE_BINARY_DIR}/lapacke_mangling.h"
)
install (FILES ${CMAKE_BINARY_DIR}/lapacke_mangling.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
endif()
string(TOUPPER ${ARCH} UC_ARCH)
-file(WRITE ${TARGET_CONF}
+file(WRITE ${TARGET_CONF_TEMP}
"#define OS_${HOST_OS}\t1\n"
"#define ARCH_${UC_ARCH}\t1\n"
"#define C_${COMPILER_ID}\t1\n"
"#define FUNDERSCORE\t${FU}\n")
if (${HOST_OS} STREQUAL "WINDOWSSTORE")
- file(APPEND ${TARGET_CONF}
+ file(APPEND ${TARGET_CONF_TEMP}
"#define OS_WINNT\t1\n")
endif ()
# TODO: set FEXTRALIB flags a la f_check?
set(BU "_")
- file(APPEND ${TARGET_CONF}
+ file(APPEND ${TARGET_CONF_TEMP}
"#define BUNDERSCORE _\n"
"#define NEEDBUNDERSCORE 1\n"
"#define NEED2UNDERSCORES 0\n")
set(NO_FBLAS 1)
#set(F_COMPILER GFORTRAN) # CMake handles the fortran compiler
set(BU "_")
- file(APPEND ${TARGET_CONF}
+ file(APPEND ${TARGET_CONF_TEMP}
"#define BUNDERSCORE _\n"
"#define NEEDBUNDERSCORE 1\n")
endif()
set(TARGET_CONF "config.h")
endif ()
+set(TARGET_CONF_TEMP "${TARGET_CONF}.tmp")
include("${PROJECT_SOURCE_DIR}/cmake/c_check.cmake")
if (NOT NOFORTRAN)
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${PROJECT_SOURCE_DIR}
+ COMPILE_DEFINITIONS ${EXFLAGS} ${GETARCH_FLAGS} -I${GETARCH_DIR} -I${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE GETARCH_LOG
COPY_FILE ${PROJECT_BINARY_DIR}/${GETARCH_BIN}
)
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} ${GETARCH_CONF_OUT})
+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${PROJECT_SOURCE_DIR}
+ COMPILE_DEFINITIONS ${EXFLAGS} ${GETARCH_FLAGS} ${GETARCH2_FLAGS} -I${GETARCH2_DIR} -I${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE GETARCH2_LOG
COPY_FILE ${PROJECT_BINARY_DIR}/${GETARCH2_BIN}
)
execute_process(COMMAND ${PROJECT_BINARY_DIR}/${GETARCH2_BIN} 1 OUTPUT_VARIABLE GETARCH2_CONF_OUT)
# append config data from getarch_2nd to the TARGET file and read in CMake vars
-file(APPEND ${TARGET_CONF} ${GETARCH2_CONF_OUT})
+file(APPEND ${TARGET_CONF_TEMP} ${GETARCH2_CONF_OUT})
+configure_file(${TARGET_CONF_TEMP} ${TARGET_CONF} COPYONLY)
ParseGetArchVars(${GETARCH2_MAKE_OUT})
# compile get_config_h
if (NOT ${GEN_CONFIG_H_RESULT})
MESSAGE(FATAL_ERROR "Compiling gen_config_h failed ${GEN_CONFIG_H_LOG}")
endif ()
-endif ()
\ No newline at end of file
+endif ()
string(REPLACE ";" "\n#define " define_source "${obj_defines}")
string(REPLACE "=" " " define_source "${define_source}")
- file(WRITE ${new_source_file} "#define ${define_source}\n#include \"${old_source_file}\"")
+ file(WRITE ${new_source_file}.tmp "#define ${define_source}\n#include \"${old_source_file}\"")
+ configure_file(${new_source_file}.tmp ${new_source_file} COPYONLY)
+ file(REMOVE ${new_source_file}.tmp)
list(APPEND SRC_LIST_OUT ${new_source_file})
endforeach ()