set(CMAKE_LDR_PE_HELPER_STANDARD_LIBRARIES "-lgcc" CACHE STRING "Standard C Libraries")
endif()
-if(NOT MSVC)
-###
-### For GCC
-###
-function(add_linker_script _target _linker_script_file)
- get_filename_component(_file_full_path ${_linker_script_file} ABSOLUTE)
- add_target_link_flags(${_target} "-Wl,-T,${_file_full_path}")
-
- # Unfortunately LINK_DEPENDS is ignored in non-Makefile generators (for now...)
- # See also http://www.cmake.org/pipermail/cmake/2010-May/037206.html
- add_target_property(${_target} LINK_DEPENDS ${_file_full_path})
-endfunction()
-
-else()
-###
-### For MSVC
-###
-function(add_linker_script _target _linker_script_file)
- get_filename_component(_file_full_path ${_linker_script_file} ABSOLUTE)
- get_filename_component(_file_name ${_linker_script_file} NAME)
- set(_generated_file_path_prefix "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_target}.dir/${_file_name}")
-
- # Generate the ASM module containing sections specifications and layout.
- set(_generated_file "${_generated_file_path_prefix}.S")
- add_custom_command(
- OUTPUT ${_generated_file}
- COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${_file_full_path}" "${_generated_file}"
- DEPENDS ${_file_full_path})
- set_source_files_properties(${_generated_file} PROPERTIES LANGUAGE "ASM" GENERATED TRUE)
- add_asm_files(freeldr_linker_file ${_generated_file})
-
- # Generate the C module containing extra sections specifications and layout,
- # as well as comment-type linker #pragma directives.
- set(_generated_file "${_generated_file_path_prefix}.c")
- add_custom_command(
- OUTPUT ${_generated_file}
- COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${_file_full_path}" "${_generated_file}"
- DEPENDS ${_file_full_path})
- set_source_files_properties(${_generated_file} PROPERTIES LANGUAGE "C" GENERATED TRUE)
- list(APPEND freeldr_linker_file ${_generated_file})
-
- # Add both files to the sources of the target.
- target_sources(${_target} PRIVATE ${freeldr_linker_file})
-
- # Create the additional linker response file.
- set(_generated_file "${_generated_file_path_prefix}.rsp")
- if(USE_CLANG_CL)
- set(_no_std_includes_flag "-nostdinc")
- else()
- set(_no_std_includes_flag "/X")
- endif()
- add_custom_command(
- #OUTPUT ${_generated_file}
- TARGET ${_target} PRE_LINK
- COMMAND ${CMAKE_C_COMPILER} /nologo ${_no_std_includes_flag} /D__LINKER__ /EP /c "${_file_full_path}" > "${_generated_file}"
- DEPENDS ${_file_full_path}
- VERBATIM)
- set_source_files_properties(${_generated_file} PROPERTIES GENERATED TRUE)
- add_target_link_flags(${_target} "@${_generated_file}")
-
- # Unfortunately LINK_DEPENDS is ignored in non-Makefile generators (for now...)
- # See also http://www.cmake.org/pipermail/cmake/2010-May/037206.html
- add_target_property(${_target} LINK_DEPENDS ${_generated_file})
-endfunction()
-
-endif()
-
-
if(MSVC)
# We don't need hotpatching
replace_compile_flags("/hotpatch" " ")
video/palette.c
video/video.c)
+list(APPEND FREELDR_BASE_ASM_SOURCE)
+
if(ARCH STREQUAL "i386")
+ list(APPEND FREELDR_BASE_ASM_SOURCE
+ arch/i386/multiboot.S)
+
list(APPEND FREELDR_COMMON_ASM_SOURCE
+ arch/i386/drvmap.S
arch/i386/entry.S
arch/i386/int386.S
arch/i386/pnpbios.S
arch/i386/i386trap.S
- arch/i386/linux.S
- arch/i386/mb.S)
+ arch/i386/linux.S)
list(APPEND FREELDR_NTLDR_SOURCE
ntldr/arch/i386/winldr.c
arch/i386/xboxrtc.c
arch/i386/xboxvideo.c
disk/scsiport.c)
- if(NOT MSVC)
- list(APPEND FREELDR_COMMON_ASM_SOURCE arch/i386/drvmap.S)
- endif()
elseif(ARCH STREQUAL "amd64")
list(APPEND FREELDR_COMMON_ASM_SOURCE
add_pch(freeldr_common include/freeldr.h PCH_SOURCE)
add_dependencies(freeldr_common bugcodes asm xdk)
-if(ARCH STREQUAL "i386" AND NOT MSVC)
- list(APPEND FREELDR_BASE_SOURCE arch/i386/multiboot.S)
## GCC builds need this extra thing for some reason...
+if(ARCH STREQUAL "i386" AND NOT MSVC)
target_link_libraries(freeldr_common mini_hal)
endif()
+add_asm_files(freeldr_base_asm ${FREELDR_BASE_ASM_SOURCE})
+
list(APPEND FREELDR_BASE_SOURCE
+ ${freeldr_base_asm}
bootmgr.c # This file is compiled with custom definitions
freeldr.c
ntldr/setupldr.c ## Strangely enough this file is needed in GCC builds
add_executable(freeldr_pe ${FREELDR_BASE_SOURCE})
add_executable(freeldr_pe_dbg EXCLUDE_FROM_ALL ${FREELDR_BASE_SOURCE})
+set_property(TARGET freeldr_pe PROPERTY ENABLE_EXPORTS TRUE)
+set_property(TARGET freeldr_pe_dbg PROPERTY ENABLE_EXPORTS TRUE)
+
if(NOT MSVC AND SEPARATE_DBG)
set_target_properties(freeldr_pe PROPERTIES LINKER_LANGUAGE LDR_PE_HELPER)
set_target_properties(freeldr_pe_dbg PROPERTIES LINKER_LANGUAGE LDR_PE_HELPER)