-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add CMAKE install target #988
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e9ccbe7
Add CMAKE install target
martin-frbg 084e457
Consolidate debug options
martin-frbg cebcca9
Update CMakeLists.txt
martin-frbg f5b028e
Update CMakeLists.txt
martin-frbg 6c7b9b7
Update CMakeLists.txt
martin-frbg ce37206
Update CMakeLists.txt
martin-frbg 81ac8aa
Update CMakeLists.txt
martin-frbg 8e7f280
Update CMakeLists.txt
martin-frbg f00baf3
Update CMakeLists.txt
martin-frbg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,10 +30,20 @@ set(NO_LAPACK 1) | |
set(NO_LAPACKE 1) | ||
endif() | ||
|
||
if(BUILD_DEBUG) | ||
set(CMAKE_BUILD_TYPE Debug) | ||
if(CMAKE_CONFIGURATION_TYPES) # multiconfig generator? | ||
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE) | ||
set(CMAKE_BUILD_TYPE | ||
Debug Debug | ||
Release Release | ||
) | ||
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() | ||
endif() | ||
|
||
if(BUILD_WITHOUT_CBLAS) | ||
|
@@ -141,8 +151,11 @@ 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) | ||
|
@@ -152,14 +165,15 @@ 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) | ||
#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 | ||
|
@@ -198,3 +212,18 @@ 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) | ||
install (TARGETS ${OpenBLAS_LIBNAME}_static DESTINATION lib) | ||
endif() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DEBUG_POSTFIX is already defined earlier, the install could be moved there to avoid duplicate code |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CMAKE_BUILD_TYPE should control debug/release builds, not the other way around, by the way this needs to be set in the cache before the project command if not already defined
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is xianyi's code from 7ac7e14, the patch only changed the indentation here.
I take it this evaluation of BUILD_DEBUG should be removed completely ?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More to the point, should this block become something like
if( NOT CMAKE_BUILD_TYPE )
set( CMAKE_BUILD_TYPE Release)
endif()
if (CMAKE_BUILD_TYPE = Debug)
set (DEBUG_POSTFIX "_d")
set(OpenBLAS_LIBNAME "${OpenBLAS_LIBNAME}_d")
else()
set (DEBUG_POSTFIX "")
endif()
which would also consolidate the definitions of DEBUG_POSTFIX as in your other comment ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have reworked the PR now to query BUILD_DEBUG only if CMAKE_BUILD_TYPE is not set, and moved the conditional appending of a debug prefix to use the cmake-provided setting.
(Apologies again for the mess of incremental commits to the same file, I was working via the web interface and do not see a means of squashing the commit history there)