Skip to content

Commit

Permalink
update build with idasdk90:
Browse files Browse the repository at this point in the history
- add _target_link_libraries_win_ea64/_target_link_libraries_win_ea32
  functions in FindIdaSdk to make the build on windows compatible
  with different versions of the sdk
- by default we are building plugin and loader with idasdk90 so we
  will use NOEA32 everywhere
  • Loading branch information
yeggor committed Nov 7, 2024
1 parent 6f64ef3 commit d7e68ed
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
32 changes: 22 additions & 10 deletions cmake/FindIdaSdk.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,7 @@ find_package_handle_standard_args(
# Define some platform specific variables for later use.
set(_so ${CMAKE_SHARED_LIBRARY_SUFFIX})
set(_so64 64${CMAKE_SHARED_LIBRARY_SUFFIX}) # An additional "64"
# _plx, _plx64, _llx, _llx64 are kept to stay compatible with older
# CMakeLists.txt files.
set(_plx ${CMAKE_SHARED_LIBRARY_SUFFIX})
set(_plx64 64${CMAKE_SHARED_LIBRARY_SUFFIX}) # An additional "64"
set(_llx ${CMAKE_SHARED_LIBRARY_SUFFIX})
set(_llx64 64${CMAKE_SHARED_LIBRARY_SUFFIX}) # An additional "64"

if(APPLE)
set(IdaSdk_PLATFORM __MAC__)
elseif(UNIX)
Expand All @@ -112,6 +107,21 @@ function(_ida_common_target_settings t ea64)
target_include_directories(${t} PUBLIC ${IdaSdk_INCLUDE_DIRS})
endfunction()

function(_target_link_libraries_win_ea64 t)
if(EXISTS ${IdaSdk_DIR}/lib/x64_win_vc_64_pro/ida.lib) # for idasdk84
target_link_libraries(${t} ${IdaSdk_DIR}/lib/x64_win_vc_64_pro/ida.lib)
elseif(EXISTS ${IdaSdk_DIR}/lib/x64_win_vc_64/ida.lib) # for idasdk90
target_link_libraries(${t} ${IdaSdk_DIR}/lib/x64_win_vc_64/ida.lib)
else()
message(FATAL_ERROR "ida.lib could not be found")
endif()
endfunction()

function(_target_link_libraries_win_ea32 t)
# Should not be used on idasdk90 and later
target_link_libraries(${t} ${IdaSdk_DIR}/lib/x64_win_vc_32_pro/ida.lib)
endfunction()

function(_ida_plugin name ea64 link_script) # ARGN contains sources
if(ea64)
set(t ${name}${_so64})
Expand Down Expand Up @@ -147,9 +157,10 @@ function(_ida_plugin name ea64 link_script) # ARGN contains sources
target_compile_options(${t} PUBLIC -Wno-non-virtual-dtor -Wno-varargs)
elseif(WIN32)
if(ea64)
target_link_libraries(${t} ${IdaSdk_DIR}/lib/x64_win_vc_64_pro/ida.lib)
_target_link_libraries_win_ea64(${t})
else()
target_link_libraries(${t} ${IdaSdk_DIR}/lib/x64_win_vc_32_pro/ida.lib)
# Not reachable when using idasdk90 and later
_target_link_libraries_win_ea32(${t})
endif()
endif()
endfunction()
Expand Down Expand Up @@ -188,9 +199,10 @@ function(_ida_loader name ea64 link_script)
target_compile_options(${t} PUBLIC -Wno-non-virtual-dtor -Wno-varargs)
elseif(WIN32)
if(ea64)
target_link_libraries(${t} ${IdaSdk_DIR}/lib/x64_win_vc_64_pro/ida.lib)
_target_link_libraries_win_ea64(${t})
else()
target_link_libraries(${t} ${IdaSdk_DIR}/lib/x64_win_vc_32_pro/ida.lib)
# Not reachable when using idasdk90 and later
_target_link_libraries_win_ea32(${t})
endif()
target_link_options(${t} PUBLIC "/EXPORT:LDSC")
endif()
Expand Down
6 changes: 4 additions & 2 deletions efiXplorer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,12 @@ if(HexRaysSdk_ROOT_DIR)
list(APPEND efiXplorer_src "efi_hexrays.cc" "efi_hexrays.h")
endif()

add_ida_plugin(efiXplorer ${PROJECT_SOURCE_DIR}/efixplorer.cc)
# remove NOEA32 to compile with SDK versions prior to idasdk90 as from IDA 90
# the EA32 is no longer required
add_ida_plugin(efiXplorer NOEA32 ${PROJECT_SOURCE_DIR}/efixplorer.cc)

set_ida_target_properties(efiXplorer PROPERTIES CXX_STANDARD 20)
ida_target_include_directories(efiXplorer PRIVATE ${IdaSdk_INCLUDE_DIRS})

add_ida_library(efiXplorer_lib ${efiXplorer_src})
add_ida_library(efiXplorer_lib NOEA32 ${efiXplorer_src})
ida_target_link_libraries(efiXplorer efiXplorer_lib)

0 comments on commit d7e68ed

Please sign in to comment.