Merge pull request #24002 from sandreenko/fixDesktopFailure
[platform/upstream/coreclr.git] / src / ilasm / CMakeLists.txt
1 project(ilasm)
2
3 add_definitions(-DUNICODE)
4 add_definitions(-D_UNICODE)
5 add_definitions(-D_FEATURE_NO_HOST)
6 add_definitions(-D__ILASM__)
7
8 add_definitions(-DFEATURE_CORECLR)
9
10 include_directories(.)
11 include_directories(../ildasm/unixcoreclrloader)
12
13 if(CLR_CMAKE_PLATFORM_UNIX)
14   add_compile_options(-fPIE)
15 endif(CLR_CMAKE_PLATFORM_UNIX)
16
17 set(ILASM_SOURCES
18   assem.cpp
19   writer.cpp
20   writer_enc.cpp
21   method.cpp
22   asmman.cpp
23   main.cpp
24   assembler.cpp
25   prebuilt/asmparse.cpp
26 )
27
28 set(ILASM_HEADERS
29   asmenum.h
30   asmman.hpp
31   asmparse.h
32   asmtemplates.h
33   assembler.h
34   binstr.h
35   class.hpp
36   ilasmpch.h
37   method.hpp
38   nvpair.h
39   typar.hpp
40 )
41
42 if(WIN32)
43   list(APPEND ILASM_SOURCES ${ILASM_HEADERS})
44
45   set(ILASM_RESOURCES Native.rc)
46   add_definitions(-DFX_VER_INTERNALNAME_STR=ilasm.exe)
47 endif(WIN32)
48
49
50 if(CLR_CMAKE_PLATFORM_UNIX)
51   # Need generate a right form of asmparse.cpp to avoid the following options.
52   # Clang also produces a bad-codegen on this prebuilt file with optimization.
53   # https://github.com/dotnet/coreclr/issues/2305
54   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-delete-non-virtual-dtor")
55   add_compile_options(-Wno-register)
56   add_compile_options(-Wno-array-bounds)
57   add_compile_options(-Wno-unused-label)
58   set_source_files_properties( prebuilt/asmparse.cpp PROPERTIES COMPILE_FLAGS "-O0" )
59 endif(CLR_CMAKE_PLATFORM_UNIX)
60
61 _add_executable(ilasm
62   ${ILASM_SOURCES}
63   ${ILASM_RESOURCES}
64 )
65
66 set(ILASM_LINK_LIBRARIES
67   utilcodestaticnohost
68   mscorpe
69   mdhotdata_full
70   corguids
71 )
72
73 if(CLR_CMAKE_PLATFORM_UNIX)
74   target_link_libraries(ilasm
75     ${ILASM_LINK_LIBRARIES}
76     ceefgen
77     unixcoreclrloader
78     utilcodestaticnohost
79     mscorrc_debug
80     coreclrpal
81     palrt
82   )
83
84   # FreeBSD and NetBSD implement dlopen(3) in libc
85   if(NOT CMAKE_SYSTEM_NAME STREQUAL FreeBSD AND NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD)
86     target_link_libraries(ilasm
87       dl
88     )
89   endif(NOT CMAKE_SYSTEM_NAME STREQUAL FreeBSD AND NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD)
90 else()
91   target_link_libraries(ilasm
92     ${ILASM_LINK_LIBRARIES}
93     coreclr
94     ole32
95     oleaut32
96     shell32
97   )
98 endif(CLR_CMAKE_PLATFORM_UNIX)
99
100 install_clr(ilasm)