Consolidate debug options

Use BUILD_DEBUG option only if CMAKE_BUILD_TYPE is not set
Consolidate debug postfixes in install target
This commit is contained in:
Martin Kroeker 2016-11-05 11:55:45 +01:00 committed by GitHub
parent e9ccbe738c
commit 084e4573c1
1 changed files with 16 additions and 18 deletions

View File

@ -30,13 +30,19 @@ set(NO_LAPACK 1)
set(NO_LAPACKE 1) set(NO_LAPACKE 1)
endif() endif()
if(BUILD_DEBUG) if( NOT CMAKE_BUILD_TYPE )
if(BUILD_DEBUG)
set(CMAKE_BUILD_TYPE Debug) set(CMAKE_BUILD_TYPE Debug)
set(OpenBLAS_LIBNAME "${OpenBLAS_LIBNAME}_d") else()
else()
set(CMAKE_BUILD_TYPE Release) set(CMAKE_BUILD_TYPE Release)
endif()
endif() endif()
if (CMAKE_BUILD_TYPE = Debug)
set(OpenBLAS_LIBNAME "${OpenBLAS_LIBNAME}_d")
endif()
if(BUILD_WITHOUT_CBLAS) if(BUILD_WITHOUT_CBLAS)
set(NO_CBLAS 1) set(NO_CBLAS 1)
endif() endif()
@ -155,18 +161,14 @@ add_subdirectory(utest)
if(NOT MSVC) if(NOT MSVC)
#only build shared library for 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}) add_library(${OpenBLAS_LIBNAME}_static 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 PROPERTIES OUTPUT_NAME ${OpenBLAS_LIBNAME})
set_target_properties(${OpenBLAS_LIBNAME}_static${DEBUG_POSTFIX} PROPERTIES CLEAN_DIRECT_OUTPUT 1) set_target_properties(${OpenBLAS_LIBNAME}_static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
if(SMP) if(SMP)
target_link_libraries(${OpenBLAS_LIBNAME} pthread) target_link_libraries(${OpenBLAS_LIBNAME} pthread)
target_link_libraries(${OpenBLAS_LIBNAME}_static${DEBUG_POSTFIX} pthread) target_link_libraries(${OpenBLAS_LIBNAME}_static pthread)
endif() endif()
#build test and ctest #build test and ctest
@ -218,9 +220,5 @@ FILE(GLOB_RECURSE INCLUDE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/*.h")
install (FILES ${INCLUDE_FILES} DESTINATION include) install (FILES ${INCLUDE_FILES} DESTINATION include)
if(NOT MSVC) if(NOT MSVC)
set(DEBUG_POSTFIX "") install (TARGETS ${OpenBLAS_LIBNAME}_static DESTINATION lib)
if(BUILD_DEBUG)
set(DEBUG_POSTFIX "_d")
endif()
install (TARGETS ${OpenBLAS_LIBNAME}_static${DEBUG_POSTFIX} DESTINATION lib)
endif() endif()