Skip to content

Commit

Permalink
Support Object libraries, add tests, add release notes, bump version …
Browse files Browse the repository at this point in the history
…number and report it
  • Loading branch information
white238 committed Feb 21, 2019
1 parent 899f0ea commit ea3eabd
Show file tree
Hide file tree
Showing 13 changed files with 289 additions and 52 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2017, Lawrence Livermore National Security, LLC.
Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC.

Produced at the Lawrence Livermore National Laboratory

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
BLT v0.1
BLT v0.2
========

[![Build Status](https://travis-ci.org/LLNL/blt.svg)](https://travis-ci.org/LLNL/blt)
Expand Down Expand Up @@ -29,7 +29,7 @@ Developers include:
Release
-------

Copyright (c) 2017, Lawrence Livermore National Security, LLC.
Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC.

Produced at the Lawrence Livermore National Laboratory.

Expand Down
35 changes: 35 additions & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# BLT Software Release Notes

Notes describing significant changes in each BLT release are documented
in this file.

The format of this file is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

The Axom project release numbers follow [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 0.2.0 - Release date 2019-02-15

### Added
- Release notes...
- Object library support through blt_add_library(... OBJECT TRUE ...)
- Now reporting BLT version through CMake cache variable BLT_VERSION
- Output CMake version and executable used during CMake step
- Clang-query support now added (Thanks David Poliakoff)

### Removed

### Deprecated

### Changed

### Fixed
- Incorrect use of cuda vs cuda_runtime targets
- Improved tutorial documentation
- Incorrect use of Fortran flags with CUDA (Thanks Robert Blake)
- Handle correctly CMake version differences with CUDA host compiler variables
(Thanks Randy Settgast)
- Handle uncrustify (version 0.68) command line option changes (--no-backup)

### Known Bugs


7 changes: 5 additions & 2 deletions SetupBLT.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2017, Lawrence Livermore National Security, LLC.
# Copyright (c) 2017-2019, Lawrence Livermore National Security, LLC.
#
# Produced at the Lawrence Livermore National Laboratory
#
Expand Down Expand Up @@ -41,7 +41,10 @@
###############################################################################

if (NOT BLT_LOADED)
set (BLT_LOADED True)
set(BLT_VERSION "0.2.0")
message(STATUS "BLT Version: ${BLT_VERSION}")

set(BLT_LOADED True)
mark_as_advanced(BLT_LOADED)

set( BLT_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR} CACHE PATH "" FORCE )
Expand Down
104 changes: 73 additions & 31 deletions cmake/BLTMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ endmacro(blt_add_target_link_flags)
##
## Output variables (name = "foo"):
## BLT_FOO_IS_REGISTERED_LIBRARY
## BLT_FOO_IS_OBJECT_LIBRARY
## BLT_FOO_DEPENDS_ON
## BLT_FOO_INCLUDES
## BLT_FOO_TREAT_INCLUDES_AS_SYSTEM
Expand All @@ -302,7 +303,7 @@ endmacro(blt_add_target_link_flags)
##------------------------------------------------------------------------------
macro(blt_register_library)

set(singleValueArgs NAME TREAT_INCLUDES_AS_SYSTEM)
set(singleValueArgs NAME OBJECT TREAT_INCLUDES_AS_SYSTEM)
set(multiValueArgs INCLUDES
DEPENDS_ON
FORTRAN_MODULES
Expand All @@ -329,6 +330,13 @@ macro(blt_register_library)
mark_as_advanced(BLT_${uppercase_name}_INCLUDES)
endif()

if( ${arg_OBJECT} )
set(BLT_${uppercase_name}_IS_OBJECT_LIBRARY ON CACHE BOOL "" FORCE)
else()
set(BLT_${uppercase_name}_IS_OBJECT_LIBRARY OFF CACHE BOOL "" FORCE)
endif()
mark_as_advanced(BLT_${uppercase_name}_IS_OBJECT_LIBRARY)

if( ${arg_TREAT_INCLUDES_AS_SYSTEM} )
set(BLT_${uppercase_name}_TREAT_INCLUDES_AS_SYSTEM ON CACHE BOOL "" FORCE)
else()
Expand Down Expand Up @@ -370,24 +378,33 @@ endmacro(blt_register_library)


##------------------------------------------------------------------------------
## blt_add_library( NAME <libname>
## SOURCES [source1 [source2 ...]]
## HEADERS [header1 [header2 ...]]
## INCLUDES [dir1 [dir2 ...]]
## DEFINES [define1 [define2 ...]]
## DEPENDS_ON [dep1 ...]
## OUTPUT_NAME [name]
## OUTPUT_DIR [dir]
## SHARED [TRUE | FALSE]
## blt_add_library( NAME <libname>
## SOURCES [source1 [source2 ...]]
## HEADERS [header1 [header2 ...]]
## INCLUDES [dir1 [dir2 ...]]
## DEFINES [define1 [define2 ...]]
## DEPENDS_ON [dep1 ...]
## OUTPUT_NAME [name]
## OUTPUT_DIR [dir]
## SHARED [TRUE | FALSE]
## OBJECT [TRUE | FALSE]
## CLEAR_PREFIX [TRUE | FALSE]
## FOLDER [name]
## FOLDER [name]
## )
##
## Adds a library target, called <libname>, to be built from the given sources.
## This macro uses the BUILD_SHARED_LIBS, which is defaulted to OFF, to determine
## whether the library will be build as shared or static. The optional boolean
## SHARED argument can be used to override this choice.
##
## The OBJECT argument creates a CMake object library. Basically it is a collection
## of compiled source files that are not archived or linked. Unlike regular CMake
## object libraries you do not have to use the $<TARGET_OBJECTS:<libname>> syntax,
## you can just use <libname>.
## Note: Object libraries do not follow CMake's transitivity rules until 3.13.
## BLT will add the various information provided in this macro in the order
## you provide them to help.
##
## The INCLUDES argument allows you to define what include directories are
## needed by any target that is dependent on this library. These will
## be inherited by CMake's target dependency rules.
Expand Down Expand Up @@ -417,19 +434,28 @@ endmacro(blt_register_library)
## FOLDER is an optional keyword to organize the target into a folder in an IDE.
## This is available when ENABLE_FOLDERS is ON and when the cmake generator
## supports this feature and will otherwise be ignored.
## Note: Do not use with header-only (INTERFACE)libraries, as this will generate
## a cmake configuration error.
## Note: Do not use with header-only (INTERFACE)libraries, as this will generate
## a cmake configuration error.
##------------------------------------------------------------------------------
macro(blt_add_library)

set(options)
set(singleValueArgs NAME OUTPUT_NAME OUTPUT_DIR HEADERS_OUTPUT_SUBDIR SHARED CLEAR_PREFIX FOLDER)
set(singleValueArgs NAME OUTPUT_NAME OUTPUT_DIR HEADERS_OUTPUT_SUBDIR SHARED OBJECT CLEAR_PREFIX FOLDER)
set(multiValueArgs SOURCES HEADERS INCLUDES DEFINES DEPENDS_ON)

# parse the arguments
cmake_parse_arguments(arg
"${options}" "${singleValueArgs}" "${multiValueArgs}" ${ARGN} )

# Default values
if(NOT DEFINED arg_OBJECT)
set(arg_OBJECT FALSE)
endif()

if(NOT DEFINED arg_SHARED)
set(arg_SHARED FALSE)
endif()

# sanity checks
if( "${arg_NAME}" STREQUAL "" )
message(FATAL_ERROR "blt_add_library() must be called with argument NAME <name>")
Expand All @@ -439,31 +465,45 @@ macro(blt_add_library)
message(FATAL_ERROR "blt_add_library(NAME ${arg_NAME} ...) called with no given sources or headers")
endif()

# Determine whether to build as a shared library. Default to global variable unless
# SHARED parameter is specified
set(_build_shared_library ${BUILD_SHARED_LIBS})
if( DEFINED arg_SHARED )
set(_build_shared_library ${arg_SHARED})
if (arg_OBJECT)
if (arg_SHARED)
message(FATAL_ERROR "blt_add_library(NAME ${arg_NAME} ...) cannot be called with both OBJECT and SHARED set to TRUE.")
endif()

if (NOT arg_SOURCES)
message(FATAL_ERROR "blt_add_library(NAME ${arg_NAME} ...) cannot create an object library with no sources.")
endif()
endif()

if ( arg_SOURCES )
# Determine type of library to build. STATIC by default and OBJECT takes
# precedence over global BUILD_SHARED_LIBS variable.
set(_build_shared_library ${BUILD_SHARED_LIBS})
if( DEFINED arg_SHARED )
set(_build_shared_library ${arg_SHARED})
endif()

if ( ${_build_shared_library} )
add_library( ${arg_NAME} SHARED ${arg_SOURCES} ${arg_HEADERS} )
set(_lib_type "SHARED")
elseif ( ${arg_OBJECT} )
set(_lib_type "OBJECT")
blt_register_library( NAME ${arg_NAME}
DEPENDS_ON ${arg_DEPENDS_ON}
INCLUDES ${arg_INCLUDES}
OBJECT TRUE
DEFINES ${arg_DEFINES} )
else()
add_library( ${arg_NAME} STATIC ${arg_SOURCES} ${arg_HEADERS} )
set(_lib_type "STATIC")
endif()

add_library( ${arg_NAME} ${_lib_type} ${arg_SOURCES} ${arg_HEADERS} )

if (ENABLE_CUDA AND NOT ENABLE_CLANG_CUDA)
if ( ${_build_shared_library} )
set(_target_type "shared")
else()
set(_target_type "static")
endif()
blt_setup_cuda_target(
NAME ${arg_NAME}
SOURCES ${arg_SOURCES}
DEPENDS_ON ${arg_DEPENDS_ON}
LIBRARY_TYPE ${_target_type})
LIBRARY_TYPE ${_lib_type})
endif()
else()
#
Expand Down Expand Up @@ -504,8 +544,9 @@ macro(blt_add_library)
target_include_directories(${arg_NAME} PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY})
endif()

blt_setup_target( NAME ${arg_NAME}
DEPENDS_ON ${arg_DEPENDS_ON} )
blt_setup_target( NAME ${arg_NAME}
DEPENDS_ON ${arg_DEPENDS_ON}
OBJECT ${arg_OBJECT})

if ( arg_INCLUDES )
target_include_directories(${arg_NAME} PUBLIC ${arg_INCLUDES})
Expand Down Expand Up @@ -609,8 +650,9 @@ macro(blt_add_executable)
target_include_directories(${arg_NAME} PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY})
endif()

blt_setup_target(NAME ${arg_NAME}
DEPENDS_ON ${arg_DEPENDS_ON} )
blt_setup_target(NAME ${arg_NAME}
DEPENDS_ON ${arg_DEPENDS_ON}
OBJECT FALSE)

if ( arg_INCLUDES )
target_include_directories(${arg_NAME} PUBLIC ${arg_INCLUDES})
Expand Down
40 changes: 25 additions & 15 deletions cmake/BLTPrivateMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,14 @@ endmacro(blt_find_executable)


##------------------------------------------------------------------------------
## blt_setup_target( NAME [name] DEPENDS_ON [dep1 ...] )
## blt_setup_target( NAME [name]
## DEPENDS_ON [dep1 ...]
## OBJECT [TRUE | FALSE])
##------------------------------------------------------------------------------
macro(blt_setup_target)

set(options)
set(singleValueArgs NAME)
set(singleValueArgs NAME OBJECT)
set(multiValueArgs DEPENDS_ON)

# Parse the arguments
Expand Down Expand Up @@ -152,6 +154,12 @@ macro(blt_setup_target)
foreach( dependency ${_expanded_DEPENDS_ON} )
string(TOUPPER ${dependency} uppercase_dependency )

if ( NOT ${arg_OBJECT} )
if ( BLT_${uppercase_dependency}_IS_OBJECT_LIBRARY )
target_sources(${arg_NAME} PRIVATE $<TARGET_OBJECTS:${dependency}>)
endif()
endif()

if ( DEFINED BLT_${uppercase_dependency}_INCLUDES )
if ( BLT_${uppercase_dependency}_TREAT_INCLUDES_AS_SYSTEM )
target_include_directories( ${arg_NAME} SYSTEM PUBLIC
Expand All @@ -167,17 +175,19 @@ macro(blt_setup_target)
${BLT_${uppercase_dependency}_FORTRAN_MODULES} )
endif()

if ( DEFINED BLT_${uppercase_dependency}_LIBRARIES)
# This prevents cmake from adding -l<library name> to the
# command line for BLT registered libraries which are not
# actual CMake targets
if(NOT "${BLT_${uppercase_dependency}_LIBRARIES}"
STREQUAL "BLT_NO_LIBRARIES" )
target_link_libraries( ${arg_NAME} PUBLIC
${BLT_${uppercase_dependency}_LIBRARIES} )
if ( NOT ${arg_OBJECT} )
if (DEFINED BLT_${uppercase_dependency}_LIBRARIES)
# This prevents cmake from adding -l<library name> to the
# command line for BLT registered libraries which are not
# actual CMake targets
if(NOT "${BLT_${uppercase_dependency}_LIBRARIES}"
STREQUAL "BLT_NO_LIBRARIES" )
target_link_libraries( ${arg_NAME} PUBLIC
${BLT_${uppercase_dependency}_LIBRARIES} )
endif()
else()
target_link_libraries( ${arg_NAME} PUBLIC ${dependency} )
endif()
else()
target_link_libraries( ${arg_NAME} PUBLIC ${dependency} )
endif()

if ( DEFINED BLT_${uppercase_dependency}_DEFINES )
Expand All @@ -190,7 +200,7 @@ macro(blt_setup_target)
FLAGS ${BLT_${uppercase_dependency}_COMPILE_FLAGS} )
endif()

if ( DEFINED BLT_${uppercase_dependency}_LINK_FLAGS )
if ( NOT ${arg_OBJECT} AND DEFINED BLT_${uppercase_dependency}_LINK_FLAGS )
blt_add_target_link_flags(TO ${arg_NAME}
FLAGS ${BLT_${uppercase_dependency}_LINK_FLAGS} )
endif()
Expand All @@ -203,7 +213,7 @@ endmacro(blt_setup_target)
## blt_setup_cuda_target(NAME <name of target>
## SOURCES <list of sources>
## DEPENDS_ON <list of dependencies>
## LIBRARY_TYPE <static or shared, blank for executables>)
## LIBRARY_TYPE <STATIC, SHARED, OBJECT, or blank for executables>)
##------------------------------------------------------------------------------
macro(blt_setup_cuda_target)

Expand Down Expand Up @@ -266,7 +276,7 @@ macro(blt_setup_cuda_target)
if (${arg_LIBRARY_TYPE} STREQUAL "static")
set_target_properties( ${arg_NAME} PROPERTIES
CMAKE_CUDA_CREATE_STATIC_LIBRARY ON)
else(${arg_LIBRARY_TYPE} STREQUAL "shared")
else()
set_target_properties( ${arg_NAME} PROPERTIES
CMAKE_CUDA_CREATE_STATIC_LIBRARY OFF)
endif()
Expand Down
4 changes: 3 additions & 1 deletion tests/internal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
# BLT Internal Testing Project
################################

################################
cmake_minimum_required(VERSION 3.1)

project(blt-example LANGUAGES C CXX)
Expand Down Expand Up @@ -231,6 +230,9 @@ message(STATUS "")
foreach(_target gtest example t_example_smoke not-a-target blt_header_only mpi)
blt_print_target_properties(TARGET ${_target})
endforeach()

add_subdirectory(src/object_library_test)

if(ENABLE_CLANGQUERY)
add_subdirectory(src/static_analysis)
endif()
Loading

0 comments on commit ea3eabd

Please sign in to comment.