From e9ccbe738c1a41938af12a7c73bc5d8c85748f38 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Wed, 19 Oct 2016 15:27:22 +0200 Subject: [PATCH 01/12] Add CMAKE install target Add CMAKE install target (copied from a patch provided by PrimarchOfTheSpaceWolves in #957) --- CMakeLists.txt | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d4a5d5466..c77600eb7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,9 +31,10 @@ set(NO_LAPACKE 1) endif() if(BUILD_DEBUG) -set(CMAKE_BUILD_TYPE Debug) + set(CMAKE_BUILD_TYPE Debug) + set(OpenBLAS_LIBNAME "${OpenBLAS_LIBNAME}_d") else() -set(CMAKE_BUILD_TYPE Release) + set(CMAKE_BUILD_TYPE Release) endif() if(BUILD_WITHOUT_CBLAS) @@ -143,6 +144,7 @@ include("${PROJECT_SOURCE_DIR}/cmake/export.cmake") set_target_properties( ${OpenBLAS_LIBNAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) foreach (OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG ) + set_target_properties( ${OpenBLAS_LIBNAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_BINARY_DIR}/lib) set_target_properties( ${OpenBLAS_LIBNAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_BINARY_DIR}/lib) set_target_properties( ${OpenBLAS_LIBNAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_BINARY_DIR}/lib) @@ -152,14 +154,19 @@ enable_testing() add_subdirectory(utest) if(NOT MSVC) -#only build shared library for MSVC -add_library(${OpenBLAS_LIBNAME}_static STATIC ${LA_SOURCES} ${LAPACKE_SOURCES} ${TARGET_OBJS}) -set_target_properties(${OpenBLAS_LIBNAME}_static PROPERTIES OUTPUT_NAME ${OpenBLAS_LIBNAME}) -set_target_properties(${OpenBLAS_LIBNAME}_static PROPERTIES CLEAN_DIRECT_OUTPUT 1) + #only build shared library for MSVC + set(DEBUG_POSTFIX "") + if(BUILD_DEBUG) + set(DEBUG_POSTFIX "_d") + endif() -if(SMP) -target_link_libraries(${OpenBLAS_LIBNAME} pthread) -target_link_libraries(${OpenBLAS_LIBNAME}_static pthread) + add_library(${OpenBLAS_LIBNAME}_static${DEBUG_POSTFIX} STATIC ${LA_SOURCES} ${LAPACKE_SOURCES} ${TARGET_OBJS}) + set_target_properties(${OpenBLAS_LIBNAME}_static${DEBUG_POSTFIX} PROPERTIES OUTPUT_NAME ${OpenBLAS_LIBNAME}) + set_target_properties(${OpenBLAS_LIBNAME}_static${DEBUG_POSTFIX} PROPERTIES CLEAN_DIRECT_OUTPUT 1) + + if(SMP) + target_link_libraries(${OpenBLAS_LIBNAME} pthread) + target_link_libraries(${OpenBLAS_LIBNAME}_static${DEBUG_POSTFIX} pthread) endif() #build test and ctest @@ -198,3 +205,22 @@ set_target_properties(${OpenBLAS_LIBNAME} PROPERTIES #endif # @touch lib.grd +# Install project + +# Install libraries +install(TARGETS ${OpenBLAS_LIBNAME} + RUNTIME DESTINATION bin + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib ) + +# Install include files +FILE(GLOB_RECURSE INCLUDE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.h") +install (FILES ${INCLUDE_FILES} DESTINATION include) + +if(NOT MSVC) + set(DEBUG_POSTFIX "") + if(BUILD_DEBUG) + set(DEBUG_POSTFIX "_d") + endif() + install (TARGETS ${OpenBLAS_LIBNAME}_static${DEBUG_POSTFIX} DESTINATION lib) +endif() From 084e4573c11f8a8e302834a4a6780e2c7da4cd88 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Sat, 5 Nov 2016 11:55:45 +0100 Subject: [PATCH 02/12] Consolidate debug options Use BUILD_DEBUG option only if CMAKE_BUILD_TYPE is not set Consolidate debug postfixes in install target --- CMakeLists.txt | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c77600eb7..01d27d551 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,13 +30,19 @@ set(NO_LAPACK 1) set(NO_LAPACKE 1) endif() -if(BUILD_DEBUG) - set(CMAKE_BUILD_TYPE Debug) - set(OpenBLAS_LIBNAME "${OpenBLAS_LIBNAME}_d") -else() - set(CMAKE_BUILD_TYPE Release) +if( NOT CMAKE_BUILD_TYPE ) + if(BUILD_DEBUG) + set(CMAKE_BUILD_TYPE Debug) + else() + set(CMAKE_BUILD_TYPE Release) + endif() endif() +if (CMAKE_BUILD_TYPE = Debug) + set(OpenBLAS_LIBNAME "${OpenBLAS_LIBNAME}_d") +endif() + + if(BUILD_WITHOUT_CBLAS) set(NO_CBLAS 1) endif() @@ -155,18 +161,14 @@ add_subdirectory(utest) if(NOT MSVC) #only build shared library for MSVC - set(DEBUG_POSTFIX "") - if(BUILD_DEBUG) - set(DEBUG_POSTFIX "_d") - endif() - add_library(${OpenBLAS_LIBNAME}_static${DEBUG_POSTFIX} STATIC ${LA_SOURCES} ${LAPACKE_SOURCES} ${TARGET_OBJS}) - set_target_properties(${OpenBLAS_LIBNAME}_static${DEBUG_POSTFIX} PROPERTIES OUTPUT_NAME ${OpenBLAS_LIBNAME}) - set_target_properties(${OpenBLAS_LIBNAME}_static${DEBUG_POSTFIX} PROPERTIES CLEAN_DIRECT_OUTPUT 1) + add_library(${OpenBLAS_LIBNAME}_static STATIC ${LA_SOURCES} ${LAPACKE_SOURCES} ${TARGET_OBJS}) + set_target_properties(${OpenBLAS_LIBNAME}_static PROPERTIES OUTPUT_NAME ${OpenBLAS_LIBNAME}) + set_target_properties(${OpenBLAS_LIBNAME}_static PROPERTIES CLEAN_DIRECT_OUTPUT 1) if(SMP) target_link_libraries(${OpenBLAS_LIBNAME} pthread) - target_link_libraries(${OpenBLAS_LIBNAME}_static${DEBUG_POSTFIX} pthread) + target_link_libraries(${OpenBLAS_LIBNAME}_static pthread) endif() #build test and ctest @@ -218,9 +220,5 @@ FILE(GLOB_RECURSE INCLUDE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.h") install (FILES ${INCLUDE_FILES} DESTINATION include) if(NOT MSVC) - set(DEBUG_POSTFIX "") - if(BUILD_DEBUG) - set(DEBUG_POSTFIX "_d") - endif() - install (TARGETS ${OpenBLAS_LIBNAME}_static${DEBUG_POSTFIX} DESTINATION lib) + install (TARGETS ${OpenBLAS_LIBNAME}_static DESTINATION lib) endif() From cebcca998796cf2dcaed0107a7268179650299eb Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Sat, 5 Nov 2016 12:47:15 +0100 Subject: [PATCH 03/12] Update CMakeLists.txt --- CMakeLists.txt | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 01d27d551..6cdbbe4e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,15 +30,23 @@ set(NO_LAPACK 1) set(NO_LAPACKE 1) endif() -if( NOT CMAKE_BUILD_TYPE ) - if(BUILD_DEBUG) - set(CMAKE_BUILD_TYPE Debug) - else() - set(CMAKE_BUILD_TYPE Release) +if(CMAKE_CONFIGURATION_TYPES) # multiconfig generator? + set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE) + set(OpenBLAS_LIBNAME + $<$:"${OpenBLAS_LIBNAME}_d"> + $<$:"${OpenBLAS_LIBNAME}"> + ) +else() + if( NOT CMAKE_BUILD_TYPE ) + if(BUILD_DEBUG) + set(CMAKE_BUILD_TYPE Debug) + else() + set(CMAKE_BUILD_TYPE Release) + endif() endif() endif() -if (CMAKE_BUILD_TYPE = Debug) +if (CMAKE_BUILD_TYPE STREQUAL Debug) set(OpenBLAS_LIBNAME "${OpenBLAS_LIBNAME}_d") endif() From f5b028eb37140e78e7b7ace58b88f7f465bcc9c3 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Sat, 5 Nov 2016 12:59:05 +0100 Subject: [PATCH 04/12] Update CMakeLists.txt --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6cdbbe4e9..551ca29d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,8 +33,8 @@ endif() if(CMAKE_CONFIGURATION_TYPES) # multiconfig generator? set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE) set(OpenBLAS_LIBNAME - $<$:"${OpenBLAS_LIBNAME}_d"> - $<$:"${OpenBLAS_LIBNAME}"> + Debug "${OpenBLAS_LIBNAME}_d" + Release "${OpenBLAS_LIBNAME}" ) else() if( NOT CMAKE_BUILD_TYPE ) From 6c7b9b74f68b8f49104c768988b65e0dbe5d5611 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Sat, 5 Nov 2016 13:05:05 +0100 Subject: [PATCH 05/12] Update CMakeLists.txt --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 551ca29d0..707f425ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,10 @@ endif() if(CMAKE_CONFIGURATION_TYPES) # multiconfig generator? set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE) + set(CMAKE_BUILD_TYPE + Debug Debug + Release Release + ) set(OpenBLAS_LIBNAME Debug "${OpenBLAS_LIBNAME}_d" Release "${OpenBLAS_LIBNAME}" From ce372062d68b38ee38ef746b375f7d363864775e Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Sat, 5 Nov 2016 13:11:32 +0100 Subject: [PATCH 06/12] Update CMakeLists.txt --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 707f425ca..397d758fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,10 +36,10 @@ if(CMAKE_CONFIGURATION_TYPES) # multiconfig generator? Debug Debug Release Release ) - set(OpenBLAS_LIBNAME - Debug "${OpenBLAS_LIBNAME}_d" - Release "${OpenBLAS_LIBNAME}" - ) +# set(OpenBLAS_LIBNAME +# Debug "${OpenBLAS_LIBNAME}_d" +# Release "${OpenBLAS_LIBNAME}" +# ) else() if( NOT CMAKE_BUILD_TYPE ) if(BUILD_DEBUG) From 81ac8aab814689b656a0ca7305d2a6b62487abe7 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Sat, 5 Nov 2016 13:26:01 +0100 Subject: [PATCH 07/12] Update CMakeLists.txt --- CMakeLists.txt | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 397d758fc..4c48476cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,10 +36,6 @@ if(CMAKE_CONFIGURATION_TYPES) # multiconfig generator? Debug Debug Release Release ) -# set(OpenBLAS_LIBNAME -# Debug "${OpenBLAS_LIBNAME}_d" -# Release "${OpenBLAS_LIBNAME}" -# ) else() if( NOT CMAKE_BUILD_TYPE ) if(BUILD_DEBUG) @@ -50,10 +46,7 @@ else() endif() endif() -if (CMAKE_BUILD_TYPE STREQUAL Debug) - set(OpenBLAS_LIBNAME "${OpenBLAS_LIBNAME}_d") -endif() - +set_target_properties (${OpenBLAS_LIBNAME} PROPERTIES OUTPUT_NAME_DEBUG "${OpenBLAS_LIBNAME}_d") if(BUILD_WITHOUT_CBLAS) set(NO_CBLAS 1) From 8e7f2809afed4862d08da44cd000ec907def1c6b Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Sat, 5 Nov 2016 13:30:40 +0100 Subject: [PATCH 08/12] Update CMakeLists.txt --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c48476cd..85397d518 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,7 +46,7 @@ else() endif() endif() -set_target_properties (${OpenBLAS_LIBNAME} PROPERTIES OUTPUT_NAME_DEBUG "${OpenBLAS_LIBNAME}_d") +set_target_properties (OpenBLAS PROPERTIES OUTPUT_NAME_DEBUG "${OpenBLAS_LIBNAME}_d") if(BUILD_WITHOUT_CBLAS) set(NO_CBLAS 1) From f00baf32a69111e6f81a38b07f4a13990d7dce31 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Sat, 5 Nov 2016 13:38:57 +0100 Subject: [PATCH 09/12] Update CMakeLists.txt --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 85397d518..a98e20c52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,8 +46,6 @@ else() endif() endif() -set_target_properties (OpenBLAS PROPERTIES OUTPUT_NAME_DEBUG "${OpenBLAS_LIBNAME}_d") - if(BUILD_WITHOUT_CBLAS) set(NO_CBLAS 1) endif() @@ -153,6 +151,8 @@ include("${PROJECT_SOURCE_DIR}/cmake/export.cmake") # Set output for libopenblas set_target_properties( ${OpenBLAS_LIBNAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) +set_target_properties( ${OpenBLAS_LIBNAME} PROPERTIES LIBRARY_OUTPUT_NAME_DEBUG "${OpenBLAS_LIBNAME}_d") + foreach (OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG ) From 570bc9afbd4d24da4174a656091df2a25980f4a7 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Sun, 6 Nov 2016 17:29:33 +0100 Subject: [PATCH 10/12] Fix spurious define in openblas_config.h TARGET as specified with make is already return-terminated when getarch reads it. This led to an empty line written to config_last.h that awk in Makefile.install then expanded to a spurious "#define OPENBLAS_" in openblas_config.h (as noted by "kmb" on the mailing list) --- getarch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/getarch.c b/getarch.c index 0c5f4def3..6602562a1 100644 --- a/getarch.c +++ b/getarch.c @@ -1098,6 +1098,7 @@ int main(int argc, char *argv[]){ p ++; } } else { + if (*p != '\n') printf("%c", *p); p ++; } From c295d61e8274746d8098fa495e7a9c4b542ca9bb Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Sun, 6 Nov 2016 17:37:37 +0100 Subject: [PATCH 11/12] Delete CMakeLists.txt --- CMakeLists.txt | 229 ------------------------------------------------- 1 file changed, 229 deletions(-) delete mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt deleted file mode 100644 index a98e20c52..000000000 --- a/CMakeLists.txt +++ /dev/null @@ -1,229 +0,0 @@ -## -## Author: Hank Anderson -## - -cmake_minimum_required(VERSION 2.8.4) -project(OpenBLAS) -set(OpenBLAS_MAJOR_VERSION 0) -set(OpenBLAS_MINOR_VERSION 2) -set(OpenBLAS_PATCH_VERSION 20.dev) -set(OpenBLAS_VERSION "${OpenBLAS_MAJOR_VERSION}.${OpenBLAS_MINOR_VERSION}.${OpenBLAS_PATCH_VERSION}") - -enable_language(ASM) -enable_language(C) - -if(MSVC) -set(OpenBLAS_LIBNAME libopenblas) -else() -set(OpenBLAS_LIBNAME openblas) -endif() - -####### -if(MSVC) -option(BUILD_WITHOUT_LAPACK "Without LAPACK and LAPACKE (Only BLAS or CBLAS)" ON) -endif() -option(BUILD_WITHOUT_CBLAS "Without CBLAS" OFF) -option(BUILD_DEBUG "Build Debug Version" OFF) -####### -if(BUILD_WITHOUT_LAPACK) -set(NO_LAPACK 1) -set(NO_LAPACKE 1) -endif() - -if(CMAKE_CONFIGURATION_TYPES) # multiconfig generator? - set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE) - set(CMAKE_BUILD_TYPE - Debug Debug - Release Release - ) -else() - if( NOT CMAKE_BUILD_TYPE ) - if(BUILD_DEBUG) - set(CMAKE_BUILD_TYPE Debug) - else() - set(CMAKE_BUILD_TYPE Release) - endif() - endif() -endif() - -if(BUILD_WITHOUT_CBLAS) -set(NO_CBLAS 1) -endif() - -####### - - -message(WARNING "CMake support is experimental. This will not produce the same Makefiles that OpenBLAS ships with. Only x86 support is currently available.") - -include("${PROJECT_SOURCE_DIR}/cmake/utils.cmake") -include("${PROJECT_SOURCE_DIR}/cmake/system.cmake") - -set(BLASDIRS interface driver/level2 driver/level3 driver/others) - -if (NOT DYNAMIC_ARCH) - list(APPEND BLASDIRS kernel) -endif () - -if (DEFINED SANITY_CHECK) - list(APPEND BLASDIRS reference) -endif () - -set(SUBDIRS ${BLASDIRS}) -if (NOT NO_LAPACK) - list(APPEND SUBDIRS lapack) -endif () - -# set which float types we want to build for -if (NOT DEFINED BUILD_SINGLE AND NOT DEFINED BUILD_DOUBLE AND NOT DEFINED BUILD_COMPLEX AND NOT DEFINED BUILD_COMPLEX16) - # if none are defined, build for all - set(BUILD_SINGLE true) - set(BUILD_DOUBLE true) - set(BUILD_COMPLEX true) - set(BUILD_COMPLEX16 true) -endif () - -set(FLOAT_TYPES "") -if (BUILD_SINGLE) - message(STATUS "Building Single Precision") - list(APPEND FLOAT_TYPES "SINGLE") # defines nothing -endif () - -if (BUILD_DOUBLE) - message(STATUS "Building Double Precision") - list(APPEND FLOAT_TYPES "DOUBLE") # defines DOUBLE -endif () - -if (BUILD_COMPLEX) - message(STATUS "Building Complex Precision") - list(APPEND FLOAT_TYPES "COMPLEX") # defines COMPLEX -endif () - -if (BUILD_COMPLEX16) - message(STATUS "Building Double Complex Precision") - list(APPEND FLOAT_TYPES "ZCOMPLEX") # defines COMPLEX and DOUBLE -endif () - -set(SUBDIRS_ALL ${SUBDIRS} test ctest utest exports benchmark ../laswp ../bench) - -# all :: libs netlib tests shared - -# libs : -if (NOT DEFINED CORE OR "${CORE}" STREQUAL "UNKNOWN") - message(FATAL_ERROR "Detecting CPU failed. Please set TARGET explicitly, e.g. make TARGET=your_cpu_target. Please read README for details.") -endif () - -if (${NO_STATIC} AND ${NO_SHARED}) - message(FATAL_ERROR "Neither static nor shared are enabled.") -endif () - -#Set default output directory -set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib ) -set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib ) - -# get obj vars into format that add_library likes: $ (see http://www.cmake.org/cmake/help/v3.0/command/add_library.html) -set(TARGET_OBJS "") -foreach (SUBDIR ${SUBDIRS}) - add_subdirectory(${SUBDIR}) - string(REPLACE "/" "_" subdir_obj ${SUBDIR}) - list(APPEND TARGET_OBJS "$") -endforeach () - -# netlib: - -# Can't just use lapack-netlib's CMake files, since they are set up to search for BLAS, build and install a binary. We just want to build a couple of lib files out of lapack and lapacke. -# Not using add_subdirectory here because lapack-netlib already has its own CMakeLists.txt. Instead include a cmake script with the sources we want. -if (NOT NOFORTRAN AND NOT NO_LAPACK) - include("${PROJECT_SOURCE_DIR}/cmake/lapack.cmake") -if (NOT NO_LAPACKE) - include("${PROJECT_SOURCE_DIR}/cmake/lapacke.cmake") -endif () -endif () - -#Only generate .def for dll on MSVC -if(MSVC) -set(OpenBLAS_DEF_FILE "${PROJECT_BINARY_DIR}/openblas.def") -endif() - -# add objects to the openblas lib -add_library(${OpenBLAS_LIBNAME} SHARED ${LA_SOURCES} ${LAPACKE_SOURCES} ${TARGET_OBJS} ${OpenBLAS_DEF_FILE}) - -include("${PROJECT_SOURCE_DIR}/cmake/export.cmake") - -# Set output for libopenblas -set_target_properties( ${OpenBLAS_LIBNAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) -set_target_properties( ${OpenBLAS_LIBNAME} PROPERTIES LIBRARY_OUTPUT_NAME_DEBUG "${OpenBLAS_LIBNAME}_d") - -foreach (OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) - string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG ) - - set_target_properties( ${OpenBLAS_LIBNAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_BINARY_DIR}/lib) - set_target_properties( ${OpenBLAS_LIBNAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_BINARY_DIR}/lib) - set_target_properties( ${OpenBLAS_LIBNAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_BINARY_DIR}/lib) -endforeach() - -enable_testing() -add_subdirectory(utest) - -if(NOT MSVC) - #only build shared library for MSVC - - add_library(${OpenBLAS_LIBNAME}_static STATIC ${LA_SOURCES} ${LAPACKE_SOURCES} ${TARGET_OBJS}) - set_target_properties(${OpenBLAS_LIBNAME}_static PROPERTIES OUTPUT_NAME ${OpenBLAS_LIBNAME}) - set_target_properties(${OpenBLAS_LIBNAME}_static PROPERTIES CLEAN_DIRECT_OUTPUT 1) - - if(SMP) - target_link_libraries(${OpenBLAS_LIBNAME} pthread) - target_link_libraries(${OpenBLAS_LIBNAME}_static pthread) -endif() - -#build test and ctest -add_subdirectory(test) -if(NOT NO_CBLAS) -add_subdirectory(ctest) -endif() -endif() - -set_target_properties(${OpenBLAS_LIBNAME} PROPERTIES - VERSION ${OpenBLAS_MAJOR_VERSION}.${OpenBLAS_MINOR_VERSION} - SOVERSION ${OpenBLAS_MAJOR_VERSION} -) - - -# TODO: Why is the config saved here? Is this necessary with CMake? -#Save the config files for installation -# @cp Makefile.conf Makefile.conf_last -# @cp config.h config_last.h -#ifdef QUAD_PRECISION -# @echo "#define QUAD_PRECISION">> config_last.h -#endif -#ifeq ($(EXPRECISION), 1) -# @echo "#define EXPRECISION">> config_last.h -#endif -### -#ifeq ($(DYNAMIC_ARCH), 1) -# @$(MAKE) -C kernel commonlibs || exit 1 -# @for d in $(DYNAMIC_CORE) ; \ -# do $(MAKE) GOTOBLAS_MAKEFILE= -C kernel TARGET_CORE=$$d kernel || exit 1 ;\ -# done -# @echo DYNAMIC_ARCH=1 >> Makefile.conf_last -#endif -#ifdef USE_THREAD -# @echo USE_THREAD=$(USE_THREAD) >> Makefile.conf_last -#endif -# @touch lib.grd - -# Install project - -# Install libraries -install(TARGETS ${OpenBLAS_LIBNAME} - RUNTIME DESTINATION bin - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib ) - -# Install include files -FILE(GLOB_RECURSE INCLUDE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.h") -install (FILES ${INCLUDE_FILES} DESTINATION include) - -if(NOT MSVC) - install (TARGETS ${OpenBLAS_LIBNAME}_static DESTINATION lib) -endif() From aaba3e483f529125ba51b9b6cbfb5f67d9b59fa8 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Sun, 6 Nov 2016 17:38:20 +0100 Subject: [PATCH 12/12] Add files via upload --- CMakeLists.txt | 200 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..d4a5d5466 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,200 @@ +## +## Author: Hank Anderson +## + +cmake_minimum_required(VERSION 2.8.4) +project(OpenBLAS) +set(OpenBLAS_MAJOR_VERSION 0) +set(OpenBLAS_MINOR_VERSION 2) +set(OpenBLAS_PATCH_VERSION 20.dev) +set(OpenBLAS_VERSION "${OpenBLAS_MAJOR_VERSION}.${OpenBLAS_MINOR_VERSION}.${OpenBLAS_PATCH_VERSION}") + +enable_language(ASM) +enable_language(C) + +if(MSVC) +set(OpenBLAS_LIBNAME libopenblas) +else() +set(OpenBLAS_LIBNAME openblas) +endif() + +####### +if(MSVC) +option(BUILD_WITHOUT_LAPACK "Without LAPACK and LAPACKE (Only BLAS or CBLAS)" ON) +endif() +option(BUILD_WITHOUT_CBLAS "Without CBLAS" OFF) +option(BUILD_DEBUG "Build Debug Version" OFF) +####### +if(BUILD_WITHOUT_LAPACK) +set(NO_LAPACK 1) +set(NO_LAPACKE 1) +endif() + +if(BUILD_DEBUG) +set(CMAKE_BUILD_TYPE Debug) +else() +set(CMAKE_BUILD_TYPE Release) +endif() + +if(BUILD_WITHOUT_CBLAS) +set(NO_CBLAS 1) +endif() + +####### + + +message(WARNING "CMake support is experimental. This will not produce the same Makefiles that OpenBLAS ships with. Only x86 support is currently available.") + +include("${PROJECT_SOURCE_DIR}/cmake/utils.cmake") +include("${PROJECT_SOURCE_DIR}/cmake/system.cmake") + +set(BLASDIRS interface driver/level2 driver/level3 driver/others) + +if (NOT DYNAMIC_ARCH) + list(APPEND BLASDIRS kernel) +endif () + +if (DEFINED SANITY_CHECK) + list(APPEND BLASDIRS reference) +endif () + +set(SUBDIRS ${BLASDIRS}) +if (NOT NO_LAPACK) + list(APPEND SUBDIRS lapack) +endif () + +# set which float types we want to build for +if (NOT DEFINED BUILD_SINGLE AND NOT DEFINED BUILD_DOUBLE AND NOT DEFINED BUILD_COMPLEX AND NOT DEFINED BUILD_COMPLEX16) + # if none are defined, build for all + set(BUILD_SINGLE true) + set(BUILD_DOUBLE true) + set(BUILD_COMPLEX true) + set(BUILD_COMPLEX16 true) +endif () + +set(FLOAT_TYPES "") +if (BUILD_SINGLE) + message(STATUS "Building Single Precision") + list(APPEND FLOAT_TYPES "SINGLE") # defines nothing +endif () + +if (BUILD_DOUBLE) + message(STATUS "Building Double Precision") + list(APPEND FLOAT_TYPES "DOUBLE") # defines DOUBLE +endif () + +if (BUILD_COMPLEX) + message(STATUS "Building Complex Precision") + list(APPEND FLOAT_TYPES "COMPLEX") # defines COMPLEX +endif () + +if (BUILD_COMPLEX16) + message(STATUS "Building Double Complex Precision") + list(APPEND FLOAT_TYPES "ZCOMPLEX") # defines COMPLEX and DOUBLE +endif () + +set(SUBDIRS_ALL ${SUBDIRS} test ctest utest exports benchmark ../laswp ../bench) + +# all :: libs netlib tests shared + +# libs : +if (NOT DEFINED CORE OR "${CORE}" STREQUAL "UNKNOWN") + message(FATAL_ERROR "Detecting CPU failed. Please set TARGET explicitly, e.g. make TARGET=your_cpu_target. Please read README for details.") +endif () + +if (${NO_STATIC} AND ${NO_SHARED}) + message(FATAL_ERROR "Neither static nor shared are enabled.") +endif () + +#Set default output directory +set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib ) +set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib ) + +# get obj vars into format that add_library likes: $ (see http://www.cmake.org/cmake/help/v3.0/command/add_library.html) +set(TARGET_OBJS "") +foreach (SUBDIR ${SUBDIRS}) + add_subdirectory(${SUBDIR}) + string(REPLACE "/" "_" subdir_obj ${SUBDIR}) + list(APPEND TARGET_OBJS "$") +endforeach () + +# netlib: + +# Can't just use lapack-netlib's CMake files, since they are set up to search for BLAS, build and install a binary. We just want to build a couple of lib files out of lapack and lapacke. +# Not using add_subdirectory here because lapack-netlib already has its own CMakeLists.txt. Instead include a cmake script with the sources we want. +if (NOT NOFORTRAN AND NOT NO_LAPACK) + include("${PROJECT_SOURCE_DIR}/cmake/lapack.cmake") +if (NOT NO_LAPACKE) + include("${PROJECT_SOURCE_DIR}/cmake/lapacke.cmake") +endif () +endif () + +#Only generate .def for dll on MSVC +if(MSVC) +set(OpenBLAS_DEF_FILE "${PROJECT_BINARY_DIR}/openblas.def") +endif() + +# add objects to the openblas lib +add_library(${OpenBLAS_LIBNAME} SHARED ${LA_SOURCES} ${LAPACKE_SOURCES} ${TARGET_OBJS} ${OpenBLAS_DEF_FILE}) + +include("${PROJECT_SOURCE_DIR}/cmake/export.cmake") + +# Set output for libopenblas +set_target_properties( ${OpenBLAS_LIBNAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib) +foreach (OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) + string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG ) + set_target_properties( ${OpenBLAS_LIBNAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_BINARY_DIR}/lib) + set_target_properties( ${OpenBLAS_LIBNAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_BINARY_DIR}/lib) + set_target_properties( ${OpenBLAS_LIBNAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_BINARY_DIR}/lib) +endforeach() + +enable_testing() +add_subdirectory(utest) + +if(NOT MSVC) +#only build shared library for MSVC +add_library(${OpenBLAS_LIBNAME}_static STATIC ${LA_SOURCES} ${LAPACKE_SOURCES} ${TARGET_OBJS}) +set_target_properties(${OpenBLAS_LIBNAME}_static PROPERTIES OUTPUT_NAME ${OpenBLAS_LIBNAME}) +set_target_properties(${OpenBLAS_LIBNAME}_static PROPERTIES CLEAN_DIRECT_OUTPUT 1) + +if(SMP) +target_link_libraries(${OpenBLAS_LIBNAME} pthread) +target_link_libraries(${OpenBLAS_LIBNAME}_static pthread) +endif() + +#build test and ctest +add_subdirectory(test) +if(NOT NO_CBLAS) +add_subdirectory(ctest) +endif() +endif() + +set_target_properties(${OpenBLAS_LIBNAME} PROPERTIES + VERSION ${OpenBLAS_MAJOR_VERSION}.${OpenBLAS_MINOR_VERSION} + SOVERSION ${OpenBLAS_MAJOR_VERSION} +) + + +# TODO: Why is the config saved here? Is this necessary with CMake? +#Save the config files for installation +# @cp Makefile.conf Makefile.conf_last +# @cp config.h config_last.h +#ifdef QUAD_PRECISION +# @echo "#define QUAD_PRECISION">> config_last.h +#endif +#ifeq ($(EXPRECISION), 1) +# @echo "#define EXPRECISION">> config_last.h +#endif +### +#ifeq ($(DYNAMIC_ARCH), 1) +# @$(MAKE) -C kernel commonlibs || exit 1 +# @for d in $(DYNAMIC_CORE) ; \ +# do $(MAKE) GOTOBLAS_MAKEFILE= -C kernel TARGET_CORE=$$d kernel || exit 1 ;\ +# done +# @echo DYNAMIC_ARCH=1 >> Makefile.conf_last +#endif +#ifdef USE_THREAD +# @echo USE_THREAD=$(USE_THREAD) >> Makefile.conf_last +#endif +# @touch lib.grd +