Skip to content

Commit

Permalink
Bump cmkr to the latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexodia committed Mar 16, 2024
1 parent 3aab37d commit 575ea08
Show file tree
Hide file tree
Showing 4 changed files with 320 additions and 146 deletions.
170 changes: 42 additions & 128 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,20 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "In-tree builds are not supported. Run CMake from a separate directory: cmake -B build")
endif()

# Regenerate CMakeLists.txt automatically in the root project
set(CMKR_ROOT_PROJECT OFF)
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(CMKR_ROOT_PROJECT ON)

# Bootstrap cmkr
# Bootstrap cmkr and automatically regenerate CMakeLists.txt
include(cmkr.cmake OPTIONAL RESULT_VARIABLE CMKR_INCLUDE_RESULT)
if(CMKR_INCLUDE_RESULT)
cmkr()
endif()

# Enable folder support
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
endif()

# Create a configure-time dependency on cmake.toml to improve IDE support
if(CMKR_ROOT_PROJECT)
# Create a configure-time dependency on cmake.toml to improve IDE support
configure_file(cmake.toml cmake.toml COPYONLY)
endif()

Expand All @@ -33,26 +30,26 @@ project(Dotx64Dbg
CXX
)

# Only have Release and Debug, there are configuration errors with managed otherwise.
SET(CMAKE_CONFIGURATION_TYPES "Debug;Release")
SET(CMAKE_VS_NUGET_PACKAGE_RESTORE ON)
include(CSharpUtilities)

# Only have Release and Debug, there are configuration errors with managed otherwise.
SET(CMAKE_CONFIGURATION_TYPES "Debug;Release")
SET(CMAKE_VS_NUGET_PACKAGE_RESTORE ON)

include(CSharpUtilities)

# Workaround for CLR projects, there is a pending fix for this:
# https://gitlab.kitware.com/cmake/cmake/-/merge_requests/7807 which corrects the exception option in use of CLR
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT}")
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG_INIT "${CMAKE_CXX_FLAGS_DEBUG_INIT}")
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
# Workaround for CLR projects, there is a pending fix for this:
# https://gitlab.kitware.com/cmake/cmake/-/merge_requests/7807 which corrects the exception option in use of CLR
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT}")
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG_INIT "${CMAKE_CXX_FLAGS_DEBUG_INIT}")
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")

if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x64)
set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x64/Dotx64Dbg)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x32)
set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x32/Dotx64Dbg)
endif()

# thirdparty
# Subdirectory: thirdparty
set(CMKR_CMAKE_FOLDER ${CMAKE_FOLDER})
if(CMAKE_FOLDER)
set(CMAKE_FOLDER "${CMAKE_FOLDER}/thirdparty")
Expand All @@ -62,17 +59,9 @@ endif()
add_subdirectory(thirdparty)
set(CMAKE_FOLDER ${CMKR_CMAKE_FOLDER})

# Target Dotx64DbgCommon
set(CMKR_TARGET Dotx64DbgCommon)
set(Dotx64DbgCommon_SOURCES "")

set(CMKR_SOURCES ${Dotx64DbgCommon_SOURCES})
# Target: Dotx64DbgCommon
add_library(Dotx64DbgCommon INTERFACE)

if(Dotx64DbgCommon_SOURCES)
target_sources(Dotx64DbgCommon INTERFACE ${Dotx64DbgCommon_SOURCES})
endif()

add_library(dotx64dbg::common ALIAS Dotx64DbgCommon)
target_compile_features(Dotx64DbgCommon INTERFACE
cxx_std_17
Expand All @@ -86,14 +75,8 @@ target_link_options(Dotx64DbgCommon INTERFACE
"/DEBUG"
)

unset(CMKR_TARGET)
unset(CMKR_SOURCES)

# Target Dotx64DbgBindings
set(CMKR_TARGET Dotx64DbgBindings)
set(Dotx64DbgBindings_SOURCES "")

list(APPEND Dotx64DbgBindings_SOURCES
# Target: Dotx64DbgBindings
set(Dotx64DbgBindings_SOURCES
"src/Bindings/Breakpoints.cpp"
"src/Bindings/Commands.cpp"
"src/Bindings/Debugger.cpp"
Expand Down Expand Up @@ -125,19 +108,12 @@ list(APPEND Dotx64DbgBindings_SOURCES
"src/Bindings/Marshal.hpp"
"src/Bindings/Mnemonic.hpp"
"src/Bindings/Register.hpp"
)

list(APPEND Dotx64DbgBindings_SOURCES
cmake.toml
)

set(CMKR_SOURCES ${Dotx64DbgBindings_SOURCES})
add_library(Dotx64DbgBindings SHARED)

if(Dotx64DbgBindings_SOURCES)
target_sources(Dotx64DbgBindings PRIVATE ${Dotx64DbgBindings_SOURCES})
endif()

target_sources(Dotx64DbgBindings PRIVATE ${Dotx64DbgBindings_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${Dotx64DbgBindings_SOURCES})

add_library(dotx64dbg::bindings ALIAS Dotx64DbgBindings)
Expand Down Expand Up @@ -179,6 +155,7 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 4) # x32
)
endif()

set(CMKR_TARGET Dotx64DbgBindings)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x64dbg.dll")
target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:x64bridge.dll")
Expand All @@ -188,14 +165,8 @@ elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
endif()
target_link_options(Dotx64DbgBindings PRIVATE "/DELAYLOAD:titanengine.dll")

unset(CMKR_TARGET)
unset(CMKR_SOURCES)

# Target Dotx64DbgManaged
set(CMKR_TARGET Dotx64DbgManaged)
set(Dotx64DbgManaged_SOURCES "")

list(APPEND Dotx64DbgManaged_SOURCES
# Target: Dotx64DbgManaged
set(Dotx64DbgManaged_SOURCES
"src/Dotx64Managed/API/Analysis/RegisterMask.cs"
"src/Dotx64Managed/API/Assembler.cs"
"src/Dotx64Managed/API/Assembler.Instructions.cs"
Expand Down Expand Up @@ -253,19 +224,12 @@ list(APPEND Dotx64DbgManaged_SOURCES
"src/Dotx64Managed/Settings.cs"
"src/Dotx64Managed/Tests.cs"
"src/Dotx64Managed/Utils.cs"
)

list(APPEND Dotx64DbgManaged_SOURCES
cmake.toml
)

set(CMKR_SOURCES ${Dotx64DbgManaged_SOURCES})
add_library(Dotx64DbgManaged SHARED)

if(Dotx64DbgManaged_SOURCES)
target_sources(Dotx64DbgManaged PRIVATE ${Dotx64DbgManaged_SOURCES})
endif()

target_sources(Dotx64DbgManaged PRIVATE ${Dotx64DbgManaged_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${Dotx64DbgManaged_SOURCES})

add_library(dotx64dbg::managed ALIAS Dotx64DbgManaged)
Expand Down Expand Up @@ -336,14 +300,8 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 8) # x64
)
endif()

unset(CMKR_TARGET)
unset(CMKR_SOURCES)

# Target Dotx64DbgTests
set(CMKR_TARGET Dotx64DbgTests)
set(Dotx64DbgTests_SOURCES "")

list(APPEND Dotx64DbgTests_SOURCES
# Target: Dotx64DbgTests
set(Dotx64DbgTests_SOURCES
"src/Dotx64DbgTests/Testing.cs"
"src/Dotx64DbgTests/Runner.cs"
"src/Dotx64DbgTests/Tests/Tests.Assembler.cs"
Expand All @@ -352,24 +310,12 @@ list(APPEND Dotx64DbgTests_SOURCES
"src/Dotx64DbgTests/Tests/Tests.Operands.cs"
"src/Dotx64DbgTests/Tests/Tests.RegisterMaskGp.cs"
"src/Dotx64DbgTests/Tests/Tests.Registers.cs"
)

list(APPEND Dotx64DbgTests_SOURCES
cmake.toml
)

set(CMKR_SOURCES ${Dotx64DbgTests_SOURCES})
add_executable(Dotx64DbgTests)

if(Dotx64DbgTests_SOURCES)
target_sources(Dotx64DbgTests PRIVATE ${Dotx64DbgTests_SOURCES})
endif()

get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY ${PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT)
if(NOT CMKR_VS_STARTUP_PROJECT)
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Dotx64DbgTests)
endif()

target_sources(Dotx64DbgTests PRIVATE ${Dotx64DbgTests_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${Dotx64DbgTests_SOURCES})

if(CMAKE_SIZEOF_VOID_P EQUAL 4) # x32
Expand Down Expand Up @@ -436,29 +382,21 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 8) # x64
)
endif()

unset(CMKR_TARGET)
unset(CMKR_SOURCES)

# Target Dotx64Dbg
set(CMKR_TARGET Dotx64Dbg)
set(Dotx64Dbg_SOURCES "")
get_directory_property(CMKR_VS_STARTUP_PROJECT DIRECTORY ${PROJECT_SOURCE_DIR} DEFINITION VS_STARTUP_PROJECT)
if(NOT CMKR_VS_STARTUP_PROJECT)
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Dotx64DbgTests)
endif()

list(APPEND Dotx64Dbg_SOURCES
# Target: Dotx64Dbg
set(Dotx64Dbg_SOURCES
"src/Dotx64Dbg/Loader.cpp"
"src/Dotx64Dbg/Plugin.cpp"
)

list(APPEND Dotx64Dbg_SOURCES
cmake.toml
)

set(CMKR_SOURCES ${Dotx64Dbg_SOURCES})
add_library(Dotx64Dbg SHARED)

if(Dotx64Dbg_SOURCES)
target_sources(Dotx64Dbg PRIVATE ${Dotx64Dbg_SOURCES})
endif()

target_sources(Dotx64Dbg PRIVATE ${Dotx64Dbg_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${Dotx64Dbg_SOURCES})

add_library(dotx64dbg::dotx64dbg ALIAS Dotx64Dbg)
Expand Down Expand Up @@ -499,28 +437,15 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 4) # x32
)
endif()

unset(CMKR_TARGET)
unset(CMKR_SOURCES)

# Target Dotx64DbgLoader
set(CMKR_TARGET Dotx64DbgLoader)
set(Dotx64DbgLoader_SOURCES "")

list(APPEND Dotx64DbgLoader_SOURCES
# Target: Dotx64DbgLoader
set(Dotx64DbgLoader_SOURCES
"src/Dotx64DbgLoader/Loader.cpp"
)

list(APPEND Dotx64DbgLoader_SOURCES
cmake.toml
)

set(CMKR_SOURCES ${Dotx64DbgLoader_SOURCES})
add_library(Dotx64DbgLoader SHARED)

if(Dotx64DbgLoader_SOURCES)
target_sources(Dotx64DbgLoader PRIVATE ${Dotx64DbgLoader_SOURCES})
endif()

target_sources(Dotx64DbgLoader PRIVATE ${Dotx64DbgLoader_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${Dotx64DbgLoader_SOURCES})

if(CMAKE_SIZEOF_VOID_P EQUAL 4) # x32
Expand Down Expand Up @@ -569,30 +494,19 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 4) # x32
)
endif()

unset(CMKR_TARGET)
unset(CMKR_SOURCES)

# Target Dotx64DbgResources
set(CMKR_TARGET Dotx64DbgResources)
set(Dotx64DbgResources_SOURCES "")

list(APPEND Dotx64DbgResources_SOURCES
# Target: Dotx64DbgResources
set(Dotx64DbgResources_SOURCES
cmake.toml
)

set(CMKR_SOURCES ${Dotx64DbgResources_SOURCES})
add_custom_target(Dotx64DbgResources SOURCES)

if(Dotx64DbgResources_SOURCES)
target_sources(Dotx64DbgResources PRIVATE ${Dotx64DbgResources_SOURCES})
endif()
target_sources(Dotx64DbgResources PRIVATE ${Dotx64DbgResources_SOURCES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${Dotx64DbgResources_SOURCES})

set(CMKR_TARGET Dotx64DbgResources)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/src/Resources
${BUILD_OUTPUT_DIR}/Resources
)

unset(CMKR_TARGET)
unset(CMKR_SOURCES)

32 changes: 18 additions & 14 deletions cmake.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,21 @@
name = "Dotx64Dbg"
languages = ["CSharp", "CXX"]
cmake-after = '''
# Only have Release and Debug, there are configuration errors with managed otherwise.
SET(CMAKE_CONFIGURATION_TYPES "Debug;Release")
SET(CMAKE_VS_NUGET_PACKAGE_RESTORE ON)
# Only have Release and Debug, there are configuration errors with managed otherwise.
SET(CMAKE_CONFIGURATION_TYPES "Debug;Release")
SET(CMAKE_VS_NUGET_PACKAGE_RESTORE ON)
include(CSharpUtilities)
# Workaround for CLR projects, there is a pending fix for this:
# https://gitlab.kitware.com/cmake/cmake/-/merge_requests/7807 which corrects the exception option in use of CLR
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT}")
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG_INIT "${CMAKE_CXX_FLAGS_DEBUG_INIT}")
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
# Workaround for CLR projects, there is a pending fix for this:
# https://gitlab.kitware.com/cmake/cmake/-/merge_requests/7807 which corrects the exception option in use of CLR
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT}")
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG_INIT "${CMAKE_CXX_FLAGS_DEBUG_INIT}")
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x64)
set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x64/Dotx64Dbg)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x32)
set(BUILD_OUTPUT_DIR ${CMAKE_SOURCE_DIR}/bin/x32/Dotx64Dbg)
endif()
'''

Expand Down Expand Up @@ -183,7 +181,13 @@ VS_GLOBAL_ProduceReferenceAssembly = "false"
VS_GLOBAL_ProduceReferenceAssemblyInOutDir = "false"
VS_GLOBAL_CopyLocalLockFileAssemblies = "true"
VS_GLOBAL_SatelliteResourceLanguages = "neutral"
VS_PACKAGE_REFERENCES = "Microsoft.CodeAnalysis.Compilers_3.10.0;NuGet.Configuration_5.11.0;NuGet.Frameworks_5.11.0;NuGet.Protocol_5.11.0;NuGet.Versioning_5.11.0"
VS_PACKAGE_REFERENCES = [
"Microsoft.CodeAnalysis.Compilers_3.10.0",
"NuGet.Configuration_5.11.0",
"NuGet.Frameworks_5.11.0",
"NuGet.Protocol_5.11.0",
"NuGet.Versioning_5.11.0"
]
VS_DOTNET_REFERENCES_COPY_LOCAL = "false"
x64.RUNTIME_OUTPUT_DIRECTORY_RELEASE = "${BUILD_OUTPUT_DIR}"
x64.RUNTIME_OUTPUT_DIRECTORY_DEBUG = "${BUILD_OUTPUT_DIR}"
Expand Down
Loading

0 comments on commit 575ea08

Please sign in to comment.