Skip to content

Commit

Permalink
Namespace generated export headers (#9)
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Cruz Viotti <[email protected]>
  • Loading branch information
jviotti authored Oct 17, 2024
1 parent 837e1ff commit caad2e1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ following:

In all cases:

- An export file on the include path called `<name>_export.h`, if the library
is not header-only
- An export file on the library include path called `<name>_export.h`, if the
library is not header-only
- The version of the library corresponds to the project version, if the library
is not header-only

Expand Down
7 changes: 4 additions & 3 deletions cmake/noa/library.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ function(noa_library)
set(INCLUDE_PREFIX "include/${NOA_LIBRARY_PROJECT}")
endif()

set(EXPORT_HEADER_PATH "${CMAKE_CURRENT_BINARY_DIR}/${INCLUDE_PREFIX}/${NOA_LIBRARY_NAME}_export.h")
if(NOT NOA_LIBRARY_VARIANT)
set(PUBLIC_HEADER "${INCLUDE_PREFIX}/${NOA_LIBRARY_NAME}.h")
else()
set(PUBLIC_HEADER "../${INCLUDE_PREFIX}/${NOA_LIBRARY_NAME}.h")
endif()

if(NOA_LIBRARY_SOURCES)
set(ABSOLUTE_PRIVATE_HEADERS "${CMAKE_CURRENT_BINARY_DIR}/${NOA_LIBRARY_NAME}_export.h")
set(ABSOLUTE_PRIVATE_HEADERS "${EXPORT_HEADER_PATH}")
else()
set(ABSOLUTE_PRIVATE_HEADERS)
endif()
Expand Down Expand Up @@ -100,15 +101,15 @@ function(noa_library)
if(NOA_LIBRARY_SOURCES)
include(GenerateExportHeader)
generate_export_header(${TARGET_NAME}
EXPORT_FILE_NAME ${NOA_LIBRARY_NAME}_export.h)
EXPORT_FILE_NAME ${EXPORT_HEADER_PATH})
set_target_properties(${TARGET_NAME}
PROPERTIES
SOVERSION "${PROJECT_VERSION_MAJOR}"
VERSION "${PROJECT_VERSION}")

# To find the generated files
target_include_directories(${TARGET_NAME}
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>")
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>")
endif()
endfunction()

Expand Down

0 comments on commit caad2e1

Please sign in to comment.