Skip to content
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

add PXR_SYMLINK_HEADER_FILES cmake option #150

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/defaults/Options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ option(PXR_ENABLE_HDF5_SUPPORT "Enable HDF5 backend in the Alembic plugin for US
option(PXR_ENABLE_PTEX_SUPPORT "Enable Ptex support" ON)
option(PXR_MAYA_TBB_BUG_WORKAROUND "Turn on linker flag (-Wl,-Bsymbolic) to work around a Maya TBB bug" OFF)
option(PXR_ENABLE_NAMESPACES "Enable C++ namespaces." ON)
option(PXR_SYMLINK_HEADER_FILES "Symlink the header files from, ie, pxr/base/lib/tf to CMAKE_DIR/pxr/base/tf, instead of copying; ensures that you may edit the header file in either location, and improves experience in IDEs which find normally the \"copied\" header, ie, CLion; has no effect on windows" OFF)

# Precompiled headers are a win on Windows, not on gcc.
set(pxr_enable_pch "OFF")
Expand Down
39 changes: 29 additions & 10 deletions cmake/macros/Private.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,36 @@ function(_install_headers LIBRARY_NAME)
set(infile "${CMAKE_CURRENT_SOURCE_DIR}/${f}")
set(outfile "${header_dest_dir}/${f}")
list(APPEND files_copied ${outfile})
add_custom_command(
if(PXR_SYMLINK_HEADER_FILES AND NOT WIN32)
# cmake -E create_symlink doesn't create parent directories, while
# copy does... so need an extra command to make dir

# Also, if ${f} has a directory, header_parent_dir will be
# different than header_dest_dir
get_filename_component(header_parent_dir ${outfile} DIRECTORY)
add_custom_command(
OUTPUT ${outfile}
COMMAND "${CMAKE_COMMAND}"
ARGS -E make_directory "${header_parent_dir}"
COMMAND "${CMAKE_COMMAND}"
ARGS -E create_symlink "${infile}" "${outfile}"
MAIN_DEPENDENCY "${infile}"
COMMENT "Symlinking ${f} ..."
VERBATIM
)
else()
add_custom_command(
OUTPUT ${outfile}
COMMAND
"${PYTHON_EXECUTABLE}"
"${PROJECT_SOURCE_DIR}/cmake/macros/copyHeaderForBuild.py"
"${infile}"
"${outfile}"
MAIN_DEPENDENCY "${infile}"
COMMENT "Copying ${f} ..."
VERBATIM
)
COMMAND
"${PYTHON_EXECUTABLE}"
"${PROJECT_SOURCE_DIR}/cmake/macros/copyHeaderForBuild.py"
"${infile}"
"${outfile}"
MAIN_DEPENDENCY "${infile}"
COMMENT "Copying ${f} ..."
VERBATIM
)
endif()
endforeach()
endif()
endfunction() # _install_headers
Expand Down