Skip to content

Commit

Permalink
Merge platform calculations into a DyninstPlatform.cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
hainest committed Dec 22, 2022
1 parent ecd39e3 commit f0eb84c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 38 deletions.
42 changes: 39 additions & 3 deletions cmake/DyninstPlatform.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
if(UNIX)
include(DyninstPlatformUnix)
include_guard(GLOBAL)

if(WIN32)
set(PLATFORM i386-unknown-nt4.0)
return()
endif()

set(PLATFORM $ENV{PLATFORM})
message(STATUS "-- Input platform: ${PLATFORM}")
set(VALID_PLATFORMS
amd64-unknown-freebsd7.2 i386-unknown-freebsd7.2 i386-unknown-linux2.4 ppc64_linux
x86_64-unknown-linux2.4 aarch64-unknown-linux)

if(NOT PLATFORM)
set(INVALID_PLATFORM true)
else()
include(DyninstPlatformWindows)
list(FIND VALID_PLATFORMS ${PLATFORM} PLATFORM_FOUND)
if(PLATFORM_FOUND EQUAL -1)
set(INVALID_PLATFORM true)
endif()
endif()

execute_process(COMMAND ${DYNINST_ROOT}/scripts/sysname OUTPUT_VARIABLE SYSNAME_OUT)
string(REPLACE "\n" "" SYSPLATFORM ${SYSNAME_OUT})

if(INVALID_PLATFORM)
# Try to set it automatically
execute_process(COMMAND ${DYNINST_ROOT}/scripts/dynsysname ${SYSNAME_OUT}
OUTPUT_VARIABLE DYNSYSNAME_OUT)
string(REPLACE "\n" "" PLATFORM ${DYNSYSNAME_OUT})
message(STATUS "-- Attempting to automatically identify platform: ${PLATFORM}")
endif()

list(FIND VALID_PLATFORMS ${PLATFORM} PLATFORM_FOUND)

if(PLATFORM_FOUND EQUAL -1)
message(
FATAL_ERROR
"Error: unknown platform ${PLATFORM}; please set the PLATFORM environment variable to one of the following options: ${VALID_PLATFORMS}"
)
endif()
34 changes: 0 additions & 34 deletions cmake/DyninstPlatformUnix.cmake

This file was deleted.

1 change: 0 additions & 1 deletion cmake/DyninstPlatformWindows.cmake

This file was deleted.

0 comments on commit f0eb84c

Please sign in to comment.