RenderKit / rkcommon

Intel RenderKit common C++/CMake infrastructure
Apache License 2.0
17 stars 10 forks source link

Using rkcommon as a submodule #3

Closed orbingol closed 3 years ago

orbingol commented 3 years ago

Hello,

I am using rkcommon as a submodule of my OSPRay -based project. In my main CMakeLists.txt file, I am adding the rkcommon directory like this

add_subdirectory(rkcommon)

After running the CMake configuration step, I am having an issue with the compilation caused by the following lines in the rkcommon CMakeLists.txt file (lines 25-30).

configure_file(
  ${CMAKE_SOURCE_DIR}/rkcommon/version.h.in
  ${CMAKE_BINARY_DIR}/rkcommon/version.h
  @ONLY
)
set(RKCOMMON_RESOURCE ${CMAKE_SOURCE_DIR}/rkcommon/rkcommon.rc)

For my setup, ${CMAKE_SOURCE_DIR} and ${CMAKE_BINARY_DIR} are referring to the main project's source and binary directories. However, version.h.in is located in the submodule directory. I think a minor update to the CMakeLists.txt file, like below, might solve this issue without breaking any existing tools.

configure_file(
  ${PROJECT_SOURCE_DIR}/rkcommon/version.h.in
  ${PROJECT_BINARY_DIR}/rkcommon/version.h
  @ONLY
)
set(RKCOMMON_RESOURCE ${PROJECT_SOURCE_DIR}/rkcommon/rkcommon.rc)

Also, updating line 46 of rkcommon/CMakeLists.txt file is needed:

target_include_directories(${PROJECT_NAME}
  PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/..>
    $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/>  # line 46 here
    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
  PRIVATE
    ${CMAKE_CURRENT_LIST_DIR}
)

I haven't tested the results thoroughly but I am guessing these changes should be okay to fix using rkcommon as a submodule.

Thanks.

johguenther commented 3 years ago

Thanks for this suggestion! We will look into it.

orbingol commented 3 years ago

Thank you! :)