Merge pull request #4068 from Lucrecious/master
[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.c
26 )
27 set_source_files_properties( prebuilt/asmparse.c PROPERTIES LANGUAGE CXX )
28
29 if(CLR_CMAKE_PLATFORM_UNIX)
30   add_compile_options(-x c++)
31   # Need generate a right form of asmparse.c to avoid the following options.
32   # Clang also produces a bad-codegen on this prebuilt file with optimization.
33   # https://github.com/dotnet/coreclr/issues/2305
34   add_compile_options(-Wno-delete-non-virtual-dtor)
35   add_compile_options(-Wno-deprecated-register)
36   add_compile_options(-Wno-array-bounds)
37   add_compile_options(-Wno-unused-label)
38   set_source_files_properties( prebuilt/asmparse.c PROPERTIES COMPILE_FLAGS -O0 )
39 endif(CLR_CMAKE_PLATFORM_UNIX)
40
41 add_executable(ilasm
42   ${ILASM_SOURCES}
43 )
44
45 set(ILASM_LINK_LIBRARIES
46   utilcodestaticnohost
47   mscorpe
48   mdhotdata_full
49   corguids
50 )
51
52 if(CLR_CMAKE_PLATFORM_UNIX)
53   target_link_libraries(ilasm
54     ${ILASM_LINK_LIBRARIES}
55     ceefgen
56     unixcoreclrloader
57     utilcodestaticnohost
58     mscorrc_debug
59     coreclrpal
60     palrt
61   )
62
63   # FreeBSD and NetBSD implement dlopen(3) in libc
64   if(NOT CMAKE_SYSTEM_NAME STREQUAL FreeBSD AND NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD)
65     target_link_libraries(ilasm
66       dl
67     )
68   endif(NOT CMAKE_SYSTEM_NAME STREQUAL FreeBSD AND NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD)
69 else()
70   target_link_libraries(ilasm
71     ${ILASM_LINK_LIBRARIES}
72     coreclr
73     msvcrt
74     ole32
75     oleaut32
76     shell32
77   )
78 endif(CLR_CMAKE_PLATFORM_UNIX)
79
80 install_clr(ilasm)