|
| 1 | + |
| 2 | +if(CMAKE_VERSION VERSION_LESS 3.18) |
| 3 | + set(DEV_MODULE Development) |
| 4 | +else() |
| 5 | + set(DEV_MODULE Development.Module) |
| 6 | +endif() |
| 7 | + |
| 8 | +find_package(Python REQUIRED COMPONENTS Interpreter ${DEV_MODULE}) |
| 9 | + |
| 10 | +# ----------------------------------------------------------------------------- |
| 11 | +# Workaround for Windows: construct Python_LIBRARY if not set |
| 12 | +# (common in CI with hostedtoolcache) |
| 13 | +# ----------------------------------------------------------------------------- |
| 14 | +if(WIN32 AND NOT DEFINED Python_LIBRARY) |
| 15 | + # Dynamically construct the Python_LIBRARY path using version info from |
| 16 | + # find_package(Python) |
| 17 | + if (NOT Python_VERSION) |
| 18 | + message(FATAL_ERROR |
| 19 | + "Python_VERSION not set after find_package(Python). " |
| 20 | + "Cannot construct Python library path." |
| 21 | + ) |
| 22 | + endif() |
| 23 | + |
| 24 | + # Split the version string into major, minor, and patch parts |
| 25 | + string(REGEX MATCH "^([0-9]+)\\.([0-9]+)\\.(.+)" _ ${Python_VERSION}) |
| 26 | + set(Python_VERSION_MAJOR ${CMAKE_MATCH_1}) |
| 27 | + set(Python_VERSION_MINOR ${CMAKE_MATCH_2}) |
| 28 | + set(Python_VERSION_PATCH ${CMAKE_MATCH_3}) |
| 29 | + |
| 30 | + set(DYNAMIC_PYTHON_LIB_FILENAME "python${Python_VERSION_MAJOR}${Python_VERSION_MINOR}.lib") |
| 31 | + set(EXPECTED_PYTHON_VERSION_DIR "C:/hostedtoolcache/windows/Python/${Python_VERSION}/x64/libs") |
| 32 | + set(Python_LIBRARY "${EXPECTED_PYTHON_VERSION_DIR}/${DYNAMIC_PYTHON_LIB_FILENAME}") |
| 33 | + |
| 34 | + message(STATUS "DEBUG: On Windows, constructed DYNAMIC_PYTHON_LIB_FILENAME: ${DYNAMIC_PYTHON_LIB_FILENAME}") |
| 35 | + message(STATUS "DEBUG: On Windows, constructed Python_LIBRARY path: ${Python_LIBRARY}") |
| 36 | +endif() |
| 37 | + |
| 38 | +if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) |
| 39 | + set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE) |
| 40 | + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS |
| 41 | + "Debug" "Release" "MinSizeRel" "RelWithDebInfo") |
| 42 | +endif() |
| 43 | + |
| 44 | +# ----------------------------------------------------------------------------- |
| 45 | +# Project-specific include and source directories for the ICS packet module. |
| 46 | +# ----------------------------------------------------------------------------- |
| 47 | +set(ICS_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/icspacket/include") |
| 48 | +set(ICS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/icspacket") |
| 49 | + |
| 50 | +# Collect all base source files under "skeletons" for compilation. This globbing |
| 51 | +# automatically pulls in all .c files. We can do that here, because the |
| 52 | +# skeletons directory is designed to store only C source and header files. |
| 53 | +file(GLOB ICS_BASE_SOURCES "${ICS_INCLUDE_DIR}/skeletons/*.c") |
| 54 | + |
| 55 | +# ----------------------------------------------------------------------------- |
| 56 | +# Optional debugging flag: |
| 57 | +# Enable ASN.1 debugging output from asn1c-generated code. |
| 58 | +# Uncomment this line during development/troubleshooting. |
| 59 | +# ----------------------------------------------------------------------------- |
| 60 | +# add_definitions(-DASN_EMIT_DEBUG=1) |
0 commit comments