Skip to content

Commit ef64991

Browse files
committed
Clean up config file writing.
1 parent 7a86708 commit ef64991

File tree

1 file changed

+23
-19
lines changed

1 file changed

+23
-19
lines changed

CMakeLists.txt

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,17 @@ if (USE_THREAD)
177177
target_link_libraries(${OpenBLAS_LIBNAME} ${CMAKE_THREAD_LIBS_INIT})
178178
endif()
179179

180-
if (NOT MSVC AND NOT NOFORTRAN)
180+
if (MSVC OR NOT NOFORTRAN)
181+
# Broken without fortran on unix
181182
add_subdirectory(utest)
183+
endif()
184+
185+
if (NOT MSVC AND NOT NOFORTRAN)
182186
# Build test and ctest
183187
add_subdirectory(test)
184188
if(NOT NO_CBLAS)
185189
add_subdirectory(ctest)
186190
endif()
187-
elseif(MSVC)
188-
add_subdirectory(utest)
189191
endif()
190192

191193
set_target_properties(${OpenBLAS_LIBNAME} PROPERTIES
@@ -201,31 +203,33 @@ install(TARGETS ${OpenBLAS_LIBNAME}
201203
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
202204
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
203205

204-
set(OPENBLAS_TMP ${CMAKE_BINARY_DIR}/openblas_config.tmp)
205-
file(WRITE ${OPENBLAS_TMP} "#ifndef OPENBLAS_CONFIG_H\n")
206-
file(APPEND ${OPENBLAS_TMP} "#define OPENBLAS_CONFIG_H\n")
206+
message(STATUS "Generating openblas_config.h in ${CMAKE_INSTALL_INCLUDEDIR}")
207+
208+
set(OPENBLAS_CONFIG_H ${CMAKE_BINARY_DIR}/openblas_config.h)
209+
file(WRITE ${OPENBLAS_CONFIG_H} "#ifndef OPENBLAS_CONFIG_H\n")
210+
file(APPEND ${OPENBLAS_CONFIG_H} "#define OPENBLAS_CONFIG_H\n")
207211
file(STRINGS ${PROJECT_BINARY_DIR}/config.h __lines)
208212
foreach(line ${__lines})
209213
string(REPLACE "#define " "" line ${line})
210-
file(APPEND ${OPENBLAS_TMP} "#define OPENBLAS_${line}\n")
214+
file(APPEND ${OPENBLAS_CONFIG_H} "#define OPENBLAS_${line}\n")
211215
endforeach()
212-
file(APPEND ${OPENBLAS_TMP} "#define OPENBLAS_VERSION \"OpenBLAS ${OpenBLAS_VERSION}\"\n")
213-
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/openblas_config_template.h __template)
214-
file(APPEND ${OPENBLAS_TMP} "${__template}")
215-
file(APPEND ${OPENBLAS_TMP} "#endif /* OPENBLAS_CONFIG_H */\n")
216-
configure_file(${OPENBLAS_TMP} ${CMAKE_BINARY_DIR}/openblas_config.h COPYONLY)
217-
218-
install (FILES ${CMAKE_BINARY_DIR}/openblas_config.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
216+
file(APPEND ${OPENBLAS_CONFIG_H} "#define OPENBLAS_VERSION \"OpenBLAS ${OpenBLAS_VERSION}\"\n")
217+
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/openblas_config_template.h OPENBLAS_CONFIG_TEMPLATE_H_CONTENTS)
218+
file(APPEND ${OPENBLAS_CONFIG_H} "${OPENBLAS_CONFIG_TEMPLATE_H_CONTENTS}\n")
219+
file(APPEND ${OPENBLAS_CONFIG_H} "#endif /* OPENBLAS_CONFIG_H */\n")
220+
install (FILES ${OPENBLAS_CONFIG_H} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
219221

220222
if(NOT NOFORTRAN)
221223
message(STATUS "Generating f77blas.h in ${CMAKE_INSTALL_INCLUDEDIR}")
222224

223-
file(WRITE ${CMAKE_BINARY_DIR}/f77blas.h "")
224-
file(APPEND ${CMAKE_BINARY_DIR}/f77blas.h "#ifndef OPENBLAS_F77BLAS_H\n#define OPENBLAS_F77BLAS_H\n#include \"openblas_config.h\"\n")
225+
set(F77BLAS_H ${CMAKE_BINARY_DIR}/f77blas.h)
226+
file(WRITE ${F77BLAS_H} "#ifndef OPENBLAS_F77BLAS_H\n")
227+
file(APPEND ${F77BLAS_H} "#define OPENBLAS_F77BLAS_H\n")
228+
file(APPEND ${F77BLAS_H} "#include \"openblas_config.h\"\n")
225229
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/common_interface.h COMMON_INTERFACE_H_CONTENTS)
226-
file(APPEND ${CMAKE_BINARY_DIR}/f77blas.h "${COMMON_INTERFACE_H_CONTENTS}")
227-
file(APPEND ${CMAKE_BINARY_DIR}/f77blas.h "#endif")
228-
install (FILES ${CMAKE_BINARY_DIR}/f77blas.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
230+
file(APPEND ${F77BLAS_H} "${COMMON_INTERFACE_H_CONTENTS}\n")
231+
file(APPEND ${F77BLAS_H} "#endif")
232+
install (FILES ${F77BLAS_H} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
229233
endif()
230234

231235
if(NOT NO_CBLAS)

0 commit comments

Comments
 (0)