@@ -3,7 +3,10 @@ cmake_minimum_required (VERSION 3.5)
33project (mifare C )
44
55set (EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR} /../script/bin)
6- set (SRC_DIR ./)
6+ set (SRC_DIR ./) # Assuming source files are in the same directory as CMakeLists.txt
7+
8+ # Define a variable for the compatibility code directory
9+ set (COMPAT_DIR ${CMAKE_CURRENT_SOURCE_DIR} /compat)
710
811set (COMMON_FILES
912 ${SRC_DIR} /common.c
@@ -229,27 +232,37 @@ if (CMAKE_SYSTEM_NAME MATCHES "Windows")
229232endif ()
230233
231234
235+ # --- hardnested Executable ---
232236add_executable (hardnested ${COMMON_FILES} ${HARDNESTED_SOURCES} )
233237# Add dependency: hardnested depends on the *imported library target*
234- # CMake handles the transitive dependency: hardnested -> liblzma_imported -> build_liblzma
235238add_dependencies (hardnested liblzma_imported ) # Keep this explicit dependency
236239
237240target_include_directories (hardnested PRIVATE
238241 ${SRC_DIR}
239242 ${HARDNESTED_RECOVERY_DIR}
240243 ${HARDNESTED_RECOVERY_DIR} /pm3
241244 ${HARDNESTED_RECOVERY_DIR} /hardnested
242- # Include dir now comes from linking liblzma_imported via INTERFACE_INCLUDE_DIRECTORIES
245+ # liblzma include dir comes via INTERFACE property of liblzma_imported
243246)
244247target_compile_options (hardnested PRIVATE -Wall )
248+
245249if (CMAKE_SYSTEM_NAME MATCHES "Linux" )
246250 target_compile_definitions (hardnested PRIVATE _GNU_SOURCE )
247251endif ()
252+
248253if (CMAKE_SYSTEM_NAME MATCHES "Windows" )
249- # NOTE: LZMA_API_STATIC definition was NOT added here, as requested
254+ # --- Add fmemopen compatibility layer for Windows ---
255+ target_sources (hardnested PRIVATE
256+ ${COMPAT_DIR} /fmemopen/fmemopen.c # Compile the source file
257+ )
258+ target_include_directories (hardnested PRIVATE
259+ ${COMPAT_DIR} /fmemopen # Add include directory for fmemopen.h
260+ )
261+ # --- End fmemopen changes ---
262+
250263 target_compile_definitions (hardnested PRIVATE
251264 HAVE_STRUCT_TIMESPEC
252- # LZMA_API_STATIC # <-- Kept commented out per request
265+ # LZMA_API_STATIC # Add this back if you get lzma linker errors
253266 )
254267 target_link_libraries (hardnested PRIVATE pthread )
255268endif ()
@@ -262,3 +275,4 @@ target_link_libraries(hardnested PRIVATE
262275
263276# Set the output directory for all executables at the end
264277set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} )
278+
0 commit comments