@@ -6,7 +6,7 @@ cmake_minimum_required(VERSION 2.8.4)
66project (OpenBLAS)
77set (OpenBLAS_MAJOR_VERSION 0)
88set (OpenBLAS_MINOR_VERSION 2)
9- set (OpenBLAS_PATCH_VERSION 16 .dev)
9+ set (OpenBLAS_PATCH_VERSION 20 .dev)
1010set (OpenBLAS_VERSION "${OpenBLAS_MAJOR_VERSION} .${OpenBLAS_MINOR_VERSION} .${OpenBLAS_PATCH_VERSION} " )
1111
1212enable_language (ASM )
@@ -30,10 +30,20 @@ set(NO_LAPACK 1)
3030set (NO_LAPACKE 1)
3131endif ()
3232
33- if (BUILD_DEBUG)
34- set (CMAKE_BUILD_TYPE Debug)
33+ if (CMAKE_CONFIGURATION_TYPES ) # multiconfig generator?
34+ set (CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE )
35+ set (CMAKE_BUILD_TYPE
36+ Debug Debug
37+ Release Release
38+ )
3539else ()
36- set (CMAKE_BUILD_TYPE Release)
40+ if ( NOT CMAKE_BUILD_TYPE )
41+ if (BUILD_DEBUG)
42+ set (CMAKE_BUILD_TYPE Debug)
43+ else ()
44+ set (CMAKE_BUILD_TYPE Release)
45+ endif ()
46+ endif ()
3747endif ()
3848
3949if (BUILD_WITHOUT_CBLAS)
@@ -45,19 +55,15 @@ endif()
4555
4656message (WARNING "CMake support is experimental. This will not produce the same Makefiles that OpenBLAS ships with. Only x86 support is currently available." )
4757
48- include ("${CMAKE_SOURCE_DIR } /cmake/utils.cmake" )
49- include ("${CMAKE_SOURCE_DIR } /cmake/system.cmake" )
58+ include ("${PROJECT_SOURCE_DIR } /cmake/utils.cmake" )
59+ include ("${PROJECT_SOURCE_DIR } /cmake/system.cmake" )
5060
5161set (BLASDIRS interface driver/level2 driver/level3 driver/others)
5262
5363if (NOT DYNAMIC_ARCH)
5464 list (APPEND BLASDIRS kernel)
5565endif ()
5666
57- if (DEFINED UTEST_CHECK)
58- set (SANITY_CHECK 1)
59- endif ()
60-
6167if (DEFINED SANITY_CHECK)
6268 list (APPEND BLASDIRS reference)
6369endif ()
@@ -110,6 +116,10 @@ if (${NO_STATIC} AND ${NO_SHARED})
110116 message (FATAL_ERROR "Neither static nor shared are enabled." )
111117endif ()
112118
119+ #Set default output directory
120+ set ( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} /lib )
121+ set ( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} /lib )
122+
113123# get obj vars into format that add_library likes: $<TARGET_OBJS:objlib> (see http://www.cmake.org/cmake/help/v3.0/command/add_library.html)
114124set (TARGET_OBJS "" )
115125foreach (SUBDIR ${SUBDIRS} )
@@ -123,9 +133,9 @@ endforeach ()
123133# 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.
124134# Not using add_subdirectory here because lapack-netlib already has its own CMakeLists.txt. Instead include a cmake script with the sources we want.
125135if (NOT NOFORTRAN AND NOT NO_LAPACK)
126- include ("${CMAKE_SOURCE_DIR } /cmake/lapack.cmake" )
136+ include ("${PROJECT_SOURCE_DIR } /cmake/lapack.cmake" )
127137if (NOT NO_LAPACKE)
128- include ("${CMAKE_SOURCE_DIR } /cmake/lapacke.cmake" )
138+ include ("${PROJECT_SOURCE_DIR } /cmake/lapacke.cmake" )
129139endif ()
130140endif ()
131141
@@ -137,22 +147,36 @@ endif()
137147# add objects to the openblas lib
138148add_library (${OpenBLAS_LIBNAME} SHARED ${LA_SOURCES} ${LAPACKE_SOURCES} ${TARGET_OBJS} ${OpenBLAS_DEF_FILE} )
139149
140- include ("${CMAKE_SOURCE_DIR} /cmake/export.cmake" )
150+ include ("${PROJECT_SOURCE_DIR} /cmake/export.cmake" )
151+
152+ # Set output for libopenblas
153+ set_target_properties ( ${OpenBLAS_LIBNAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} /lib )
154+ set_target_properties ( ${OpenBLAS_LIBNAME} PROPERTIES LIBRARY_OUTPUT_NAME_DEBUG "${OpenBLAS_LIBNAME} _d" )
141155
156+ foreach (OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
157+ string ( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
158+
159+ set_target_properties ( ${OpenBLAS_LIBNAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_BINARY_DIR} /lib )
160+ set_target_properties ( ${OpenBLAS_LIBNAME} PROPERTIES LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_BINARY_DIR} /lib )
161+ set_target_properties ( ${OpenBLAS_LIBNAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_BINARY_DIR} /lib )
162+ endforeach ()
163+
164+ enable_testing ()
165+ add_subdirectory (utest )
142166
143167if (NOT MSVC )
144- #only build shared library for MSVC
145- add_library (${OpenBLAS_LIBNAME} _static STATIC ${LA_SOURCES} ${LAPACKE_SOURCES} ${TARGET_OBJS} )
146- set_target_properties (${OpenBLAS_LIBNAME} _static PROPERTIES OUTPUT_NAME ${OpenBLAS_LIBNAME} )
147- set_target_properties (${OpenBLAS_LIBNAME} _static PROPERTIES CLEAN_DIRECT_OUTPUT 1 )
148-
149- if (SMP)
150- target_link_libraries (${OpenBLAS_LIBNAME} pthread )
151- target_link_libraries (${OpenBLAS_LIBNAME} _static pthread )
168+ #only build shared library for MSVC
169+
170+ add_library (${OpenBLAS_LIBNAME} _static STATIC ${LA_SOURCES} ${LAPACKE_SOURCES} ${TARGET_OBJS} )
171+ set_target_properties (${OpenBLAS_LIBNAME} _static PROPERTIES OUTPUT_NAME ${OpenBLAS_LIBNAME} )
172+ set_target_properties (${OpenBLAS_LIBNAME} _static PROPERTIES CLEAN_DIRECT_OUTPUT 1 )
173+
174+ if (SMP)
175+ target_link_libraries (${OpenBLAS_LIBNAME} pthread )
176+ target_link_libraries (${OpenBLAS_LIBNAME} _static pthread )
152177endif ()
153178
154179#build test and ctest
155- enable_testing ()
156180add_subdirectory (test )
157181if (NOT NO_CBLAS)
158182add_subdirectory (ctest )
@@ -188,3 +212,27 @@ set_target_properties(${OpenBLAS_LIBNAME} PROPERTIES
188212#endif
189213# @touch lib.grd
190214
215+ # Install project
216+
217+ # Install libraries
218+ install (TARGETS ${OpenBLAS_LIBNAME}
219+ RUNTIME DESTINATION bin
220+ ARCHIVE DESTINATION lib
221+ LIBRARY DESTINATION lib )
222+
223+ # Install include files
224+ FILE (GLOB_RECURSE INCLUDE_FILES "${CMAKE_CURRENT_SOURCE_DIR} /*.h" )
225+ install (FILES ${INCLUDE_FILES} DESTINATION include)
226+
227+ if (NOT MSVC )
228+ install (TARGETS ${OpenBLAS_LIBNAME} _static DESTINATION lib)
229+ endif ()
230+
231+ include (FindPkgConfig QUIET )
232+ if (PKG_CONFIG_FOUND)
233+ set (prefix ${CMAKE_INSTALL_PREFIX} )
234+ set (libdir ${CMAKE_INSTALL_PREFIX} /lib)
235+ set (includedir ${CMAKE_INSTALL_PREFIX} /include)
236+ configure_file (${PROJECT_SOURCE_DIR} /cmake/openblas.pc.in ${PROJECT_BINARY_DIR} /openblas.pc @ONLY )
237+ install (FILES ${PROJECT_BINARY_DIR} /openblas.pc DESTINATION lib/pkgconfig/)
238+ endif ()
0 commit comments