One-click running in CLion
This commit is contained in:
parent
1cebb489d7
commit
0beed2c4f1
|
@ -31,7 +31,6 @@ project(x64dbg
|
|||
"An open-source x64/x32 debugger for windows."
|
||||
)
|
||||
|
||||
include("cmake/Qt5Helpers.cmake")
|
||||
include("cmake/VSFlags.cmake")
|
||||
|
||||
# Packages
|
||||
|
@ -814,12 +813,17 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 8) # x64
|
|||
)
|
||||
endif()
|
||||
|
||||
set(CMKR_TARGET gui)
|
||||
# Enable Qt moc/rrc/uic support
|
||||
target_qt(${CMKR_TARGET})
|
||||
set_target_properties(gui PROPERTIES
|
||||
AUTOMOC
|
||||
ON
|
||||
AUTORCC
|
||||
ON
|
||||
AUTOUIC
|
||||
ON
|
||||
)
|
||||
|
||||
# Copy Qt DLLs next to the application
|
||||
target_windeployqt(${CMKR_TARGET})
|
||||
set(CMKR_TARGET gui)
|
||||
include("cmake/deps.cmake")
|
||||
|
||||
# Target: loaddll
|
||||
set(loaddll_SOURCES
|
||||
|
@ -896,6 +900,7 @@ target_link_libraries(exe PRIVATE
|
|||
if(MSVC) # msvc
|
||||
target_link_options(exe PRIVATE
|
||||
"/DEF:${CMAKE_SOURCE_DIR}/src/exe/signaturecheck.def"
|
||||
"/INCREMENTAL:NO"
|
||||
)
|
||||
endif()
|
||||
|
||||
|
@ -927,6 +932,10 @@ if(NOT CMKR_VS_STARTUP_PROJECT)
|
|||
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT exe)
|
||||
endif()
|
||||
|
||||
set(CMKR_TARGET exe)
|
||||
# Make the executable the main target
|
||||
add_dependencies(exe dbg gui deps)
|
||||
|
||||
# Target: launcher
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4) # x86
|
||||
set(launcher_SOURCES
|
||||
|
|
17
cmake.toml
17
cmake.toml
|
@ -9,7 +9,6 @@ include-before = [
|
|||
"cmake/VSToolchain.cmake"
|
||||
]
|
||||
include-after = [
|
||||
"cmake/Qt5Helpers.cmake",
|
||||
"cmake/VSFlags.cmake",
|
||||
]
|
||||
|
||||
|
@ -171,17 +170,14 @@ private-compile-definitions = [
|
|||
"BUILD_LIB",
|
||||
"NOMINMAX",
|
||||
]
|
||||
cmake-after = """
|
||||
# Enable Qt moc/rrc/uic support
|
||||
target_qt(${CMKR_TARGET})
|
||||
|
||||
# Copy Qt DLLs next to the application
|
||||
target_windeployqt(${CMKR_TARGET})
|
||||
"""
|
||||
include-after = ["cmake/deps.cmake"]
|
||||
|
||||
[target.gui.properties]
|
||||
x86.OUTPUT_NAME = "x32gui"
|
||||
x64.OUTPUT_NAME = "x64gui"
|
||||
AUTOMOC = true
|
||||
AUTORCC = true
|
||||
AUTOUIC = true
|
||||
|
||||
[target.loaddll]
|
||||
type = "executable"
|
||||
|
@ -215,7 +211,12 @@ link-libraries = [
|
|||
]
|
||||
msvc.link-options = [
|
||||
"/DEF:${CMAKE_SOURCE_DIR}/src/exe/signaturecheck.def",
|
||||
"/INCREMENTAL:NO",
|
||||
]
|
||||
cmake-after = """
|
||||
# Make the executable the main target
|
||||
add_dependencies(exe dbg gui deps)
|
||||
"""
|
||||
|
||||
[target.exe.properties]
|
||||
x86.OUTPUT_NAME = "x32dbg"
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
# https://github.com/mrexodia/Qt5CMakeTemplate
|
||||
# License: BSL-1.0
|
||||
|
||||
# Make the project look nicer in IDEs
|
||||
set_property(GLOBAL PROPERTY AUTOGEN_SOURCE_GROUP "Generated Files")
|
||||
set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER "CMakePredefinedTargets")
|
||||
|
||||
# Install Visual Studio runtime
|
||||
include(InstallRequiredSystemLibraries)
|
||||
|
||||
# Helper function to enable moc/rcc/uic
|
||||
function(target_qt target)
|
||||
set_target_properties(${target} PROPERTIES
|
||||
AUTOMOC
|
||||
ON
|
||||
AUTORCC
|
||||
ON
|
||||
AUTOUIC
|
||||
ON
|
||||
)
|
||||
endfunction()
|
||||
|
||||
# Helper function to deploy Qt DLLs
|
||||
function(target_windeployqt deploy_target)
|
||||
# Based on: https://stackoverflow.com/a/41199492/1806760
|
||||
# TODO: set VCINSTALLDIR environment variable to copy MSVC runtime DLLs
|
||||
if(Qt5_FOUND AND WIN32 AND TARGET Qt5::qmake AND NOT TARGET Qt5::windeployqt)
|
||||
get_target_property(_qt5_qmake_location Qt5::qmake IMPORTED_LOCATION)
|
||||
|
||||
execute_process(
|
||||
COMMAND "${_qt5_qmake_location}" -query QT_INSTALL_PREFIX
|
||||
RESULT_VARIABLE return_code
|
||||
OUTPUT_VARIABLE qt5_install_prefix
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
set(imported_location "${qt5_install_prefix}/bin/windeployqt.exe")
|
||||
|
||||
if(EXISTS ${imported_location})
|
||||
add_executable(Qt5::windeployqt IMPORTED)
|
||||
|
||||
set_target_properties(Qt5::windeployqt PROPERTIES
|
||||
IMPORTED_LOCATION ${imported_location}
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(TARGET Qt5::windeployqt AND NOT TARGET ${deploy_target}-windeployqt)
|
||||
# Create a target that rebuilds when cmake is re-run
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${deploy_target}-windeployqt.c" "static void foo() { }\n")
|
||||
add_library(${deploy_target}-windeployqt STATIC
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${deploy_target}-windeployqt.c"
|
||||
)
|
||||
set_target_properties(${deploy_target}-windeployqt PROPERTIES
|
||||
FOLDER "CMakePredefinedTargets"
|
||||
)
|
||||
|
||||
# Execute windeployqt in a tmp directory after build
|
||||
add_custom_command(TARGET ${deploy_target}-windeployqt
|
||||
POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E remove_directory "${CMAKE_CURRENT_BINARY_DIR}/${deploy_target}-windeployqt"
|
||||
COMMAND Qt5::windeployqt --no-compiler-runtime --dir "${CMAKE_CURRENT_BINARY_DIR}/${deploy_target}-windeployqt" "$<TARGET_FILE:${deploy_target}>"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_BINARY_DIR}/${deploy_target}-windeployqt" "$<TARGET_FILE_DIR:${deploy_target}>"
|
||||
)
|
||||
|
||||
# Copy deployment directory during installation
|
||||
install(
|
||||
DIRECTORY
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${deploy_target}-windeployqt/"
|
||||
DESTINATION bin
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
|
@ -12,3 +12,11 @@ if(MSVC)
|
|||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG:FULL /INCREMENTAL:NO /OPT:REF /OPT:ICF" CACHE STRING "")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "/DEBUG:FULL /INCREMENTAL:NO /OPT:REF /OPT:ICF" CACHE STRING "")
|
||||
endif()
|
||||
|
||||
# Make the project look nicer in IDEs
|
||||
set_property(GLOBAL PROPERTY AUTOGEN_SOURCE_GROUP "Generated Files")
|
||||
set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER "CMakePredefinedTargets")
|
||||
set_property(GLOBAL PROPERTY AUTOMOC_SOURCE_GROUP "Generated Files")
|
||||
set_property(GLOBAL PROPERTY AUTOMOC_TARGETS_FOLDER "CMakePredefinedTargets")
|
||||
set_property(GLOBAL PROPERTY AUTORCC_SOURCE_GROUP "Generated Files")
|
||||
set_property(GLOBAL PROPERTY AUTORCC_TARGETS_FOLDER "CMakePredefinedTargets")
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
if(CMAKE_SCRIPT_MODE_FILE)
|
||||
set(GUI_DLL ${CMAKE_ARGV3})
|
||||
set(DEPS_DIR ${CMAKE_ARGV4})
|
||||
set(WINDEPLOYQT ${CMAKE_ARGV5})
|
||||
get_filename_component(GUI_DIR ${GUI_DLL} DIRECTORY)
|
||||
|
||||
# Check if we already copied the dependencies
|
||||
if(EXISTS "${GUI_DIR}/.deps_copied")
|
||||
return()
|
||||
endif()
|
||||
|
||||
message(STATUS "Copying dependencies from ${DEPS_DIR} to ${GUI_DIR}")
|
||||
|
||||
execute_process(COMMAND ${WINDEPLOYQT} --no-compiler-runtime ${GUI_DLL})
|
||||
|
||||
function(copy_dep relfile)
|
||||
if(EXISTS ${relfile})
|
||||
message(STATUS "Skipping ${relfile}")
|
||||
return()
|
||||
endif()
|
||||
message(STATUS "Copying ${relfile}")
|
||||
get_filename_component(reldir ${relfile} DIRECTORY)
|
||||
get_filename_component(relfile ${relfile} NAME)
|
||||
file(COPY ${DEPS_DIR}/${relfile} DESTINATION ${GUI_DIR}/${reldir})
|
||||
endfunction()
|
||||
|
||||
file(GLOB DEPS RELATIVE ${DEPS_DIR} "${DEPS_DIR}/*.dll")
|
||||
foreach(DEP ${DEPS})
|
||||
if(NOT DEP MATCHES "^(Qt5|msvc)")
|
||||
copy_dep(${DEP})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
copy_dep(GleeBug/TitanEngine.dll)
|
||||
copy_dep(StaticEngine/TitanEngine.dll)
|
||||
|
||||
file(TOUCH "${GUI_DIR}/.deps_copied")
|
||||
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(NOT WIN32)
|
||||
message(STATUS "copy_dependencies is only supported on Windows")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(NOT TARGET Qt5::windeployqt AND Qt5_FOUND AND TARGET Qt5::qmake)
|
||||
get_target_property(_qt5_qmake_location Qt5::qmake IMPORTED_LOCATION)
|
||||
|
||||
execute_process(
|
||||
COMMAND "${_qt5_qmake_location}" -query QT_INSTALL_PREFIX
|
||||
RESULT_VARIABLE return_code
|
||||
OUTPUT_VARIABLE qt5_install_prefix
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
set(imported_location "${qt5_install_prefix}/bin/windeployqt.exe")
|
||||
if(NOT EXISTS ${imported_location})
|
||||
message(FATAL_ERROR "Qt5 tool not found: ${imported_location}")
|
||||
endif()
|
||||
|
||||
add_executable(Qt5::windeployqt IMPORTED)
|
||||
|
||||
set_target_properties(Qt5::windeployqt PROPERTIES
|
||||
IMPORTED_LOCATION ${imported_location}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(DEPS_DIR ${CMAKE_SOURCE_DIR}/deps/x64)
|
||||
else()
|
||||
set(DEPS_DIR ${CMAKE_SOURCE_DIR}/deps/x32)
|
||||
endif()
|
||||
|
||||
add_custom_target(deps
|
||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_LIST_DIR}/deps.cmake $<TARGET_FILE:gui> ${DEPS_DIR} $<TARGET_FILE:Qt5::windeployqt>
|
||||
)
|
Loading…
Reference in New Issue