Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 200 additions & 0 deletions ports/beaengine/0001-CMakeLists.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ca8b756..1420cc4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,9 +1,7 @@
project (BeaEngine)
-cmake_minimum_required (VERSION 2.6)
+cmake_minimum_required (VERSION 3.15)

-set (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
-
-set (CMAKE_VERBOSE_MAKEFILE ON)
+cmake_policy(SET CMP0091 NEW)

option (optHAS_OPTIMIZED "Turn Optimizations ON" OFF)
option (optHAS_SYMBOLS "Build with debug Symbols" ON)
@@ -13,61 +11,36 @@ option (optBUILD_STDCALL "Build using stdcall" OFF)
option (optBUILD_LITE "Build without text disassembly" OFF)
option (USE_CLANG "build application with clang" OFF)

-if (optHAS_OPTIMIZED)
- if (optHAS_SYMBOLS)
- set (CMAKE_BUILD_TYPE RelWithDebInfo)
- else (optHAS_SYMBOLS)
- set (CMAKE_BUILD_TYPE Release)
- endif (optHAS_SYMBOLS)
-else (optHAS_OPTIMIZED)
- if (optHAS_SYMBOLS)
- set (CMAKE_BUILD_TYPE Debug)
- else (optHAS_SYMBOLS)
- set (CMAKE_BUILD_TYPE Debug)
- endif (optHAS_SYMBOLS)
-endif (optHAS_OPTIMIZED)

# determine BEA_COMPILER
if (NOT BEA_COMPILER)
- if (${CMAKE_SYSTEM_NAME} STREQUAL Linux)
- if (WATCOM)
- set (BEA_COMPILER watcom)
- else ()
- if (USE_CLANG)
- set (BEA_COMPILER clang)
- else ()
- set (BEA_COMPILER gnu)
+ if (USE_CLANG)
+ set(BEA_COMPILER clang)
+ else()
+ if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
+ set(BEA_COMPILER gnu)
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set(BEA_COMPILER clang)
+ elseif (CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+ set(BEA_COMPILER msvc)
+ elseif (CMAKE_C_COMPILER_ID MATCHES "Intel")
+ set(BEA_COMPILER intel)
+ elseif (CMAKE_C_COMPILER_ID MATCHES "SunPro")
+ set(BEA_COMPILER suncc)
+ elseif (CMAKE_C_COMPILER_ID MATCHES "Watcom")
+ set(BEA_COMPILER watcom)
+ else()
+ if (BORLAND)
+ set(BEA_COMPILER borland)
+ elseif (MINGW OR MSYS OR CYGWIN)
+ set(BEA_COMPILER gnu)
+ else()
+ message(WARNING "Unknown compiler ID '${CMAKE_C_COMPILER_ID}'. Defaulting to 'gnu'. Set BEA_COMPILER manually if this is incorrect.")
+ set(BEA_COMPILER gnu)
endif()
- endif ()
- endif ()
- if (${CMAKE_SYSTEM_NAME} STREQUAL FreeBSD)
- set (BEA_COMPILER gnu)
- endif ()
- if (${CMAKE_SYSTEM_NAME} STREQUAL SunOS)
- set (BEA_COMPILER suncc)
- endif ()
- if (${CMAKE_SYSTEM_NAME} STREQUAL Windows)
- if (MINGW OR MSYS)
- set (BEA_COMPILER gnu)
- else ()
- if (CYGWIN)
- set (BEA_COMPILER gnu)
- else ()
- if (BORLAND)
- set (BEA_COMPILER borland)
- else ()
- if (MSVC)
- set (BEA_COMPILER msvc)
- else ()
- if (WATCOM)
- set (BEA_COMPILER watcom)
- endif ()
- endif ()
- endif ()
- endif ()
- endif ()
- endif ()
-endif ()
+ endif()
+ endif()
+endif()
# =========================================
# clang configuration
# =========================================
@@ -152,20 +125,36 @@ if (BEA_COMPILER STREQUAL msvc)
endif ()
endif ()

- # determine code generation model
- if (optHAS_OPTIMIZED)
- if (optBUILD_DLL)
- list (APPEND BEA_FLAGS /MD)
- else ()
- list (APPEND BEA_FLAGS /MT)
- endif ()
- else ()
- if (optBUILD_DLL)
- list (APPEND BEA_FLAGS /MDd)
- else ()
- list (APPEND BEA_FLAGS /MTd)
- endif ()
- endif ()
+ # Determine CRT linkage model
+ # First check if CMAKE_MSVC_RUNTIME_LIBRARY is set (CMake 3.15+)
+ if (DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
+ if (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL "MultiThreaded")
+ list(APPEND BEA_FLAGS /MT)
+ elseif (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL "MultiThreadedDLL")
+ list(APPEND BEA_FLAGS /MD)
+ elseif (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL "MultiThreadedDebug")
+ list(APPEND BEA_FLAGS /MTd)
+ elseif (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL "MultiThreadedDebugDLL")
+ list(APPEND BEA_FLAGS /MDd)
+ endif()
+ else()
+ # Fallback based on build configuration options
+ if (optHAS_OPTIMIZED)
+ if (optBUILD_DLL)
+ list(APPEND BEA_FLAGS /MD)
+ else()
+ list(APPEND BEA_FLAGS /MT)
+ endif()
+ else()
+ if (optBUILD_DLL)
+ list(APPEND BEA_FLAGS /MDd)
+ else()
+ list(APPEND BEA_FLAGS /MTd)
+ endif()
+ endif()
+ endif()
+
+ message(STATUS "BeaEngine MSVC: optHAS_OPTIMIZED=${optHAS_OPTIMIZED}, optBUILD_DLL=${optBUILD_DLL}, CMAKE_MSVC_RUNTIME_LIBRARY=${CMAKE_MSVC_RUNTIME_LIBRARY}")
endif ()
# =========================================
# Intel Compiler configuration
@@ -308,6 +297,18 @@ endforeach ()
# pass compiler flags to cmake
# ================================================

+# For MSVC, remove default runtime flags that CMake adds automatically
+if (MSVC)
+ foreach(flag_var
+ CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
+ CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
+ CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
+ CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
+ # Remove any existing /MD, /MT, /MDd, /MTd flags
+ string(REGEX REPLACE "/M[DT]d?" "" ${flag_var} "${${flag_var}}")
+ endforeach()
+endif()
+
if (${CMAKE_BUILD_TYPE} STREQUAL RelWithDebInfo)
set (CMAKE_C_FLAGS_RELWITHDEBINFO ${myC_FLAGS})
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO ${myCXX_FLAGS})
@@ -354,7 +355,7 @@ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${myBIN_OUTPUT})



-FIND_PACKAGE (ZLIB)
+find_package(ZLIB REQUIRED)


set (build_modules
@@ -366,14 +367,14 @@ set (build_modules
if (NOT ZLIB_FOUND)
set (ZLIB_INCLUDE_DIR unittest/thirdparty/zlib)
else ()
- list (APPEND BEA_LIBS_PATH ${ZLIB_LIBRARIES})
+ list (APPEND BEA_LIBS_PATH ZLIB::ZLIB)
endif ()


add_definitions (${BEA_DEFINITIONS})
include_directories (${BEA_SRC_ROOT} ${BEA_INCLUDE_PATH}
${CMAKE_SOURCE_DIR} ${ZLIB_INCLUDE_DIR})
-link_directories (${BEA_LIBS_PATH})
+link_libraries (${BEA_LIBS_PATH})


set (BEA_TARGET "BeaEngine")
35 changes: 35 additions & 0 deletions ports/beaengine/0002-support-install.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e8fcb05..97629c3 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -7,3 +7,30 @@ else ()
add_library (${BEA_TARGET} STATIC BeaEngine.c)
set_target_properties (${BEA_TARGET} PROPERTIES COMPILE_FLAGS "-DBEA_ENGINE_STATIC")
endif ()
+# Override export name target_link_libraries(main PRIVATE beaengine::BeaEngine_s_d_l => beaengine::beaengine
+set_target_properties(${BEA_TARGET} PROPERTIES EXPORT_NAME "beaengine")
+install(DIRECTORY
+ "${PROJECT_SOURCE_DIR}/include/beaengine"
+ DESTINATION "include"
+ FILES_MATCHING PATTERN "*.h")
+install(TARGETS ${BEA_TARGET}
+ EXPORT beaengine-targets
+ RUNTIME DESTINATION "bin"
+ ARCHIVE DESTINATION "lib"
+ LIBRARY DESTINATION "lib"
+ INCLUDES DESTINATION "include"
+ )
+install(EXPORT beaengine-targets NAMESPACE beaengine:: DESTINATION "share/beaengine")
+include(CMakePackageConfigHelpers)
+configure_package_config_file(
+"${CMAKE_CURRENT_LIST_DIR}/beaengine-config.cmake.in"
+"${CMAKE_CURRENT_BINARY_DIR}/beaengine-config.cmake"
+INSTALL_DESTINATION "share/beaengine"
+)
+write_basic_package_version_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/beaengine-config-version.cmake" VERSION "${VERSION}" COMPATIBILITY SameMajorVersion)
+install(FILES
+ "${CMAKE_CURRENT_BINARY_DIR}/beaengine-config.cmake"
+ "${CMAKE_CURRENT_BINARY_DIR}/beaengine-config-version.cmake"
+ DESTINATION "share/beaengine"
+)
5 changes: 5 additions & 0 deletions ports/beaengine/beaengine-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
find_dependency(ZLIB REQUIRED)
include("${CMAKE_CURRENT_LIST_DIR}/beaengine-targets.cmake")
check_required_components(beaengine)
40 changes: 40 additions & 0 deletions ports/beaengine/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO BeaEngine/beaengine
REF "v${VERSION}"
SHA512 df3e1b937cce8dd79e41ce0fd6dbb263b71ec0bff27bc1b9329e12bce401e42567d4b5bb4e22a5880cfcc43d0615e6e49669993e6797def47011748ed9cdfdb4
HEAD_REF master
PATCHES
0001-CMakeLists.patch
0002-support-install.patch
)

file(COPY "${CMAKE_CURRENT_LIST_DIR}/beaengine-config.cmake.in" DESTINATION "${SOURCE_PATH}/src")

string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" BEAENGINE_BUILD_SHARED)

set(extra_config)

if(VCPKG_TARGET_IS_WINDOWS)
if(VCPKG_CRT_LINKAGE STREQUAL "dynamic")
list(APPEND extra_config -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$$<$$<CONFIG:Debug>:Debug>DLL)
else()
list(APPEND extra_config -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$$<$$<CONFIG:Debug>:Debug>)
endif()
endif()

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DoptBUILD_DLL=${BEAENGINE_BUILD_SHARED}
-DVERSION=${VERSION}
${extra_config}
)

vcpkg_cmake_install()
vcpkg_cmake_config_fixup()
vcpkg_copy_pdbs()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include" "${CURRENT_PACKAGES_DIR}/debug/share")

vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/src/COPYING.txt" "${SOURCE_PATH}/src/COPYING.LESSER.txt")
18 changes: 18 additions & 0 deletions ports/beaengine/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "beaengine",
"version": "5.3.0",
"description": "BeaEngine is a C library designed to decode instructions from 16 bits, 32 bits and 64 bits intel architectures.",
"homepage": "https://github.com/BeaEngine/beaengine",
"license": "LGPL-3.0-or-later",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
},
"zlib"
]
}
5 changes: 5 additions & 0 deletions scripts/test_ports/vcpkg-ci-beaengine/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
vcpkg_cmake_configure(
SOURCE_PATH "${CURRENT_PORT_DIR}/project"
)
vcpkg_cmake_build()
11 changes: 11 additions & 0 deletions scripts/test_ports/vcpkg-ci-beaengine/project/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 3.25.1)

project(beaengine-test LANGUAGES C)

set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)

find_package(beaengine CONFIG REQUIRED)
add_executable(main main.c)

target_link_libraries(main PRIVATE beaengine::beaengine)
7 changes: 7 additions & 0 deletions scripts/test_ports/vcpkg-ci-beaengine/project/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <stdio.h>
#include <beaengine/BeaEngine.h>
int main()
{
printf("Using BeaEngine version %s-%s.\n", BeaEngineVersion(), BeaEngineRevision());
return 0;
}
12 changes: 12 additions & 0 deletions scripts/test_ports/vcpkg-ci-beaengine/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "vcpkg-ci-beaengine",
"version-string": "ci",
"description": "Validates beaengine",
"dependencies": [
"beaengine",
{
"name": "vcpkg-cmake",
"host": true
}
]
}
9 changes: 9 additions & 0 deletions versions/b-/beaengine.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "ed12d4fb3359eb745816d37c4d758bed5c35febb",
"version": "5.3.0",
"port-version": 0
}
]
}
4 changes: 4 additions & 0 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,10 @@
"baseline": "8.2.10",
"port-version": 0
},
"beaengine": {
"baseline": "5.3.0",
"port-version": 0
},
"beast": {
"baseline": "0",
"port-version": 2
Expand Down
Loading