Require qt creator to locate the cmake project to build on non-windows

* Previously the cmake build would put librenderdoc.so in a /bin folder
  in the source folder so the qt creator project could link against a
  fixed path when just opening the project solo.
* This won't scale though for fetching the SWIG outputs from cmake, and
  it's ugly to modify the source folder for out-of-source builds.
* Instead we have cmake generate a qt creator include file with all of
  the settings and paths needed, and pass the CMAKE_BINARY_DIR into
  qmake when building. This does mean that when opening the project in
  qt creator you need to specify CMAKE_DIR=/path/to/build though.
* As a bonus, this means we can let cmake identify where python is and
  have qt creator link against it rather than having to hardcode include
  paths etc.
This commit is contained in:
baldurk
2017-03-17 11:42:44 +00:00
parent fd6fce7a78
commit 2e87ca4531
4 changed files with 32 additions and 17 deletions
+24 -4
View File
@@ -1,5 +1,3 @@
set(output_dir ${CMAKE_BINARY_DIR}/bin)
get_git_hash(GIT_COMMIT_HASH)
string(STRIP ${GIT_COMMIT_HASH} GIT_COMMIT_HASH)
@@ -53,17 +51,39 @@ else()
add_custom_command(OUTPUT RenderDoc.icns COMMAND touch RenderDoc.icns)
endif()
# Output our configuration for qmake. We output this to a separate file so that
# the user can then open the qrenderdoc.pro in qt creator and be able to build
# with these configuration entries propagated for e.g. linking against libraries
# and finding dependencies from the cmake build
file(WRITE
${CMAKE_BINARY_DIR}/qrenderdoc/qrenderdoc_cmake.pri
"CONFIG+=${QMAKE_CONFIG}\n"
"\n"
"QMAKE_CC=${CMAKE_C_COMPILER}\n"
"QMAKE_CXX=${CMAKE_CXX_COMPILER}\n"
"QMAKE_LINK=${CMAKE_CXX_COMPILER}\n"
"QMAKE_CXXFLAGS+=${warning_flags}\n"
"QMAKE_CXXFLAGS+=${QMAKE_CXXFLAGS}\n"
"QMAKE_LFLAGS+=${QMAKE_LDFLAGS}\n"
"\n"
# search for -lrenderdoc here
"LIBS+=-L${CMAKE_RUNTIME_OUTPUT_DIRECTORY}\n"
"DEFINES+=GIT_COMMIT_HASH_LITERAL=${GIT_COMMIT_HASH}\n"
"\n"
"RENDERDOC_VERSION=${RENDERDOC_VERSION}\n"
"\n"
"OSX_ICONFILE=${CMAKE_CURRENT_BINARY_DIR}/RenderDoc.icns\n")
# The case here is deliberately not matching the executable name
# This means the custom command doesn't create this output file,
# which causes CMake to rerun this target every time so that Qt
# can do dependency checking and rebuild anything necessary.
add_custom_command(OUTPUT QRenderDoc
COMMAND qmake "CONFIG+=${QMAKE_CONFIG}" "QMAKE_CC=${CMAKE_C_COMPILER}" "QMAKE_CXX=${CMAKE_CXX_COMPILER}" "QMAKE_LINK=${CMAKE_CXX_COMPILER}" "QMAKE_CXXFLAGS+=${warning_flags}" "QMAKE_CXXFLAGS+=${QMAKE_CXXFLAGS}" "QMAKE_LFLAGS+=${QMAKE_LDFLAGS}" "DEFINES+=GIT_COMMIT_HASH_LITERAL=${GIT_COMMIT_HASH}" "RENDERDOC_VERSION=${RENDERDOC_VERSION}" "DESTDIR=${output_dir}" "OSX_ICONFILE=${CMAKE_CURRENT_BINARY_DIR}/RenderDoc.icns" ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND qmake "CMAKE_DIR=${CMAKE_BINARY_DIR}" ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND $(MAKE)
DEPENDS RenderDoc.icns)
add_custom_target(build-qrenderdoc ALL DEPENDS QRenderDoc DEPENDS renderdoc)
install (PROGRAMS ${output_dir}/qrenderdoc DESTINATION bin)
install (PROGRAMS ${CMAKE_BINARY_DIR}/bin/qrenderdoc DESTINATION bin)
# Install supporting files for file associations etc
install (FILES share/application-x-renderdoc-capture.svg DESTINATION share/icons/hicolor/scalable/mimetypes/)
+8 -4
View File
@@ -68,10 +68,14 @@ win32 {
DEFINES += RENDERDOC_PLATFORM_WIN32
} else {
isEmpty(DESTDIR) {
DESTDIR = $$_PRO_FILE_PWD_/../bin
isEmpty(CMAKE_DIR) {
error("When run from outside CMake, please set the Build Environment Variable CMAKE_DIR to point to your CMake build root. In Qt Creator add CMAKE_DIR=/path/to/renderdoc/build under 'Additional arguments' in the qmake Build Step. If running qmake directly, add CMAKE_DIR=/path/to/renderdoc/build/ to the command line.")
}
DESTDIR=$$CMAKE_DIR/bin
include($$CMAKE_DIR/qrenderdoc/qrenderdoc_cmake.pri)
# Temp files into .obj
MOC_DIR = .obj
UI_DIR = .obj
@@ -79,7 +83,7 @@ win32 {
OBJECTS_DIR = .obj
# Link against the core library
LIBS += -L$$DESTDIR -lrenderdoc
LIBS += -lrenderdoc
QMAKE_LFLAGS += '-Wl,-rpath,\'\$$ORIGIN\',-rpath,\'\$$ORIGIN/../lib\''
CONFIG += warn_off
@@ -91,7 +95,7 @@ win32 {
DEFINES += RENDERDOC_PLATFORM_POSIX RENDERDOC_PLATFORM_APPLE
ICON = $$OSX_ICONFILE
INFO_PLIST_PATH = $$shell_quote($${DESTDIR}/$${TARGET}.app/Contents/Info.plist)
INFO_PLIST_PATH = $$shell_quote($$DESTDIR/$${TARGET}.app/Contents/Info.plist)
QMAKE_POST_LINK += /usr/libexec/PlistBuddy -c \"Add :CFBundleShortVersionString string $${RENDERDOC_VERSION}.0\" -c \"Set :CFBundleIdentifier org.renderdoc.qrenderdoc\" $${INFO_PLIST_PATH}
} else {
QT += x11extras
-4
View File
@@ -308,7 +308,3 @@ install (TARGETS renderdoc DESTINATION lib${LIB_SUFFIX})
# Copy in application API header to include
install (FILES api/app/renderdoc_app.h DESTINATION include RENAME renderdoc.h)
add_custom_command(TARGET renderdoc POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_SOURCE_DIR}/bin/)
add_custom_command(TARGET renderdoc POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:renderdoc> ${CMAKE_SOURCE_DIR}/bin/)
-5
View File
@@ -56,11 +56,6 @@ target_link_libraries(renderdoccmd ${libraries})
install (TARGETS renderdoccmd DESTINATION bin)
add_custom_command(TARGET renderdoccmd POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_SOURCE_DIR}/bin/)
add_custom_command(TARGET renderdoccmd POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:renderdoccmd> ${CMAKE_SOURCE_DIR}/bin/)
if(ANDROID)
set(APK_TARGET_ID "1" CACHE STRING "The Target ID to build the APK for, use <android list targets> to choose another one.")