1 include(${CLR_DIR}/dac.cmake)
2 add_definitions(-DFEATURE_NO_HOST)
4 if(CLR_CMAKE_PLATFORM_UNIX)
5 add_compile_options(-fPIC)
6 endif(CLR_CMAKE_PLATFORM_UNIX)
11 add_definitions(-DFX_VER_INTERNALNAME_STR=mscordaccore.dll)
14 list(APPEND CLR_DAC_SOURCES
21 set(CURRENT_BINARY_DIR_FOR_CONFIG ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})
23 #Preprocess exports definition file
24 preprocess_def_file(${CMAKE_CURRENT_SOURCE_DIR}/${DEF_SOURCES} ${CURRENT_BINARY_DIR_FOR_CONFIG}/mscordac.def)
26 #create target to add file dependency on mscordac.def
27 add_custom_target(mscordaccore_def DEPENDS ${CURRENT_BINARY_DIR_FOR_CONFIG}/mscordac.def)
29 # No library groups for Win32
30 set(START_LIBRARY_GROUP)
31 set(END_LIBRARY_GROUP)
33 set(DEF_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/mscordac_unixexports.src)
34 set(EXPORTS_FILE ${CMAKE_CURRENT_BINARY_DIR}/mscordac.exports)
35 generate_exports_file(${DEF_SOURCES} ${EXPORTS_FILE})
38 if(CLR_CMAKE_PLATFORM_LINUX OR CLR_CMAKE_PLATFORM_FREEBSD OR CLR_CMAKE_PLATFORM_NETBSD)
39 # This option is necessary to ensure that the overloaded delete operator defined inside
40 # of the utilcode will be used instead of the standard library delete operator.
41 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Xlinker -Bsymbolic -Xlinker -Bsymbolic-functions")
43 # The following linked options can be inserted into the linker libraries list to
44 # ensure proper resolving of circular references between a subset of the libraries.
45 set(START_LIBRARY_GROUP -Wl,--start-group)
46 set(END_LIBRARY_GROUP -Wl,--end-group)
48 # These options are used to force every object to be included even if it's unused.
49 set(START_WHOLE_ARCHIVE -Wl,--whole-archive)
50 set(END_WHOLE_ARCHIVE -Wl,--no-whole-archive)
52 # Add linker exports file option
53 set(EXPORTS_LINKER_OPTION -Wl,--version-script=${EXPORTS_FILE})
54 endif(CLR_CMAKE_PLATFORM_LINUX OR CLR_CMAKE_PLATFORM_FREEBSD OR CLR_CMAKE_PLATFORM_NETBSD)
56 if(CLR_CMAKE_PLATFORM_DARWIN)
57 # Add linker exports file option
58 set(EXPORTS_LINKER_OPTION -Wl,-exported_symbols_list,${EXPORTS_FILE})
59 endif(CLR_CMAKE_PLATFORM_DARWIN)
61 # Create object library to enable creation of proper dependency of mscordaccore.exp on mscordac.obj and
62 # mscordaccore on both the mscordaccore.exp and mscordac.obj.
63 add_library(mscordacobj OBJECT mscordac.cpp)
65 add_library_clr(mscordaccore SHARED ${CLR_DAC_SOURCES} $<TARGET_OBJECTS:mscordacobj>)
67 if(CLR_CMAKE_PLATFORM_UNIX)
68 add_custom_target(mscordaccore_exports DEPENDS ${EXPORTS_FILE})
69 add_dependencies(mscordaccore mscordaccore_exports)
71 set_property(TARGET mscordaccore APPEND_STRING PROPERTY LINK_FLAGS ${EXPORTS_LINKER_OPTION})
72 set_property(TARGET mscordaccore APPEND_STRING PROPERTY LINK_DEPENDS ${EXPORTS_FILE})
73 endif(CLR_CMAKE_PLATFORM_UNIX)
75 # IMPORTANT! Please do not rearrange the order of the libraries. The linker on Linux is
76 # order dependent and changing the order can result in undefined symbols in the shared
79 ${START_LIBRARY_GROUP} # Start group of libraries that have circular references
92 ${END_LIBRARY_GROUP} # End group of libraries that have circular references
96 # mscordac.def should be generated before mscordaccore.dll is built
97 add_dependencies(mscordaccore mscordaccore_def)
99 set(MSCORDAC_OBJ_PATH "${CMAKE_CURRENT_BINARY_DIR}/mscordacobj.dir/${CMAKE_CFG_INTDIR}/mscordac.obj")
101 # Generate export file
103 DEPENDS mscordaccore_def "${CURRENT_BINARY_DIR_FOR_CONFIG}/mscordac.def" mscordacobj daccess
104 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mscordaccore.exp
105 COMMAND lib.exe /OUT:"${CMAKE_CURRENT_BINARY_DIR}/mscordaccore.lib" /DEF:"${CURRENT_BINARY_DIR_FOR_CONFIG}/mscordac.def" "$<TARGET_FILE:daccess>" $<$<OR:$<CONFIG:Release>,$<CONFIG:Relwithdebinfo>>:/LTCG> ${STATIC_LIBRARY_FLAGS} ${MSCORDAC_OBJ_PATH}
106 COMMENT "Generating mscordaccore.exp export file"
109 set_source_files_properties(
110 ${CMAKE_CURRENT_BINARY_DIR}/mscordaccore.exp
111 PROPERTIES GENERATED TRUE
114 add_custom_target(mscordaccore_exp DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/mscordaccore.exp)
115 add_dependencies(mscordaccore mscordaccore_exp)
117 set(COREDAC_LIBRARIES
118 ${CMAKE_CURRENT_BINARY_DIR}/mscordaccore.exp # export file
128 ${STATIC_MT_VCRT_LIB}
131 list(APPEND COREDAC_LIBRARIES
133 ${START_WHOLE_ARCHIVE} # force all PAL objects to be included so all exports are available
140 target_link_libraries(mscordaccore PRIVATE ${COREDAC_LIBRARIES})
142 # add the install targets
143 install_clr(mscordaccore)