Mercurial > pub > dyncall > dyncall
comparison CMakeLists.txt @ 371:451299d50c1a
- windows arm64 support (dyncall, dyncallback, cmake support for armasm64), thanks Bernhard Urban-Forster!
- minor cleanups
author | Tassilo Philipp |
---|---|
date | Fri, 25 Dec 2020 18:07:39 +0100 |
parents | dc8bbffc39e6 |
children | 3c3e321875f7 |
comparison
equal
deleted
inserted
replaced
370:fa78490381f3 | 371:451299d50c1a |
---|---|
1 # Package: dyncall | 1 # Package: dyncall |
2 # File: CMakeLists.txt | 2 # File: CMakeLists.txt |
3 # Description: DynCall Project cmake files | 3 # Description: DynCall Project cmake files |
4 # License: | 4 # License: |
5 # | 5 # |
6 # Copyright (c) 2010 Daniel Adler <dadler@uni-goettingen.de> | 6 # Copyright (c) 2010-2020 Daniel Adler <dadler@uni-goettingen.de> |
7 # 2020 armasm64 support: Bernhard Urban-Forster <beurba@microsoft.com> | |
7 # | 8 # |
8 # Permission to use, copy, modify, and distribute this software for any | 9 # Permission to use, copy, modify, and distribute this software for any |
9 # purpose with or without fee is hereby granted, provided that the above | 10 # purpose with or without fee is hereby granted, provided that the above |
10 # copyright notice and this permission notice appear in all copies. | 11 # copyright notice and this permission notice appear in all copies. |
11 # | 12 # |
42 endif() | 43 endif() |
43 | 44 |
44 include(CheckCCompilerFlag) | 45 include(CheckCCompilerFlag) |
45 check_c_compiler_flag("-fPIC -Werror" COMPILER_HAS_FPIC) | 46 check_c_compiler_flag("-fPIC -Werror" COMPILER_HAS_FPIC) |
46 | 47 |
48 | |
49 # compile_asm(TARGET target ASM_FILES file1 [file2 ...] OUTPUT_OBJECTS [variableName]) | |
50 # CMake does not support the ARM or ARM64 assemblers on Windows when using the | |
51 # MSBuild generator. | |
52 # credit to dotnet/runtime: | |
53 # https://github.com/dotnet/runtime/blob/e98fb61d8b4bb6687ccddead861d8b140751647b/eng/native/functions.cmake#L173-L207 | |
54 function(compile_asm) | |
55 set(options "") | |
56 set(oneValueArgs TARGET OUTPUT_OBJECTS) | |
57 set(multiValueArgs ASM_FILES) | |
58 cmake_parse_arguments(COMPILE_ASM "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGV}) | |
59 | |
60 set (ASSEMBLED_OBJECTS "") | |
61 | |
62 foreach(ASM_FILE ${COMPILE_ASM_ASM_FILES}) | |
63 get_filename_component(name ${ASM_FILE} NAME_WE) | |
64 # Produce object file where CMake would store .obj files for an OBJECT library. | |
65 # ex: artifacts\obj\coreclr\windows.arm64.Debug\src\vm\wks\cee_wks.dir\Debug\AsmHelpers.obj | |
66 set (OBJ_FILE "${CMAKE_CURRENT_BINARY_DIR}/${COMPILE_ASM_TARGET}.dir/${CMAKE_CFG_INTDIR}/${name}.obj") | |
67 | |
68 # Need to compile asm file using custom command as include directories are not provided to asm compiler | |
69 add_custom_command(OUTPUT ${OBJ_FILE} | |
70 COMMAND "${CMAKE_ASM_COMPILER}" ${ASM_INCLUDE_DIRECTORIES} -o ${OBJ_FILE} ${ASM_FILE} | |
71 DEPENDS ${ASM_FILE} | |
72 COMMENT "Assembling ${ASM_FILE} ---> \"${CMAKE_ASM_COMPILER}\" ${ASM_INCLUDE_DIRECTORIES} -o ${OBJ_FILE} ${ASM_FILE}"+ COMMENT "Assembling ${ASM_FILE} ---> \"${CMAKE_ASM_COMPILER}\" ${ASM_INCLUDE_DIRECTORIES} -o ${OBJ_FILE} ${ASM_FILE}") | |
73 | |
74 # mark obj as source that does not require compile | |
75 set_source_files_properties(${OBJ_FILE} PROPERTIES EXTERNAL_OBJECT TRUE) | |
76 | |
77 # Add the generated OBJ in the dependency list so that it gets consumed during linkage | |
78 list(APPEND ASSEMBLED_OBJECTS ${OBJ_FILE}) | |
79 endforeach() | |
80 | |
81 set(${COMPILE_ASM_OUTPUT_OBJECTS} ${ASSEMBLED_OBJECTS} PARENT_SCOPE) | |
82 endfunction() | |
83 | |
84 | |
47 if(MSVC) | 85 if(MSVC) |
48 enable_language(ASM_MASM) | 86 if("${CMAKE_GENERATOR_PLATFORM}" MATCHES "ARM64") |
49 #if(CMAKE_SIZEOF_VOID_P MATCHES 8) | 87 # Explicitly specify the assembler to be used for Arm64 compile |
50 # set(CMAKE_ASM_COMPILER "ml64") | 88 file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}\\bin\\HostX64\\arm64\\armasm64.exe" CMAKE_ASM_COMPILER) |
51 #else() | 89 # file(TO_CMAKE_PATH "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.28.29333\\bin\\HostX64\\arm64\\armasm64.exe" CMAKE_ASM_COMPILER) |
52 # set(CMAKE_ASM_COMPILER "ml") | 90 |
53 #endif() | 91 set(CMAKE_ASM_MASM_COMPILER ${CMAKE_ASM_COMPILER}) |
54 #set(CMAKE_ASM_COMPILER_ARG1 "/c") | 92 message("CMAKE_ASM_MASM_COMPILER explicitly set to: ${CMAKE_ASM_MASM_COMPILER}") |
55 #set(CMAKE_ASM_MASM_SOURCE_FILE_EXTENSIONS asm) | 93 # Enable generic assembly compilation to avoid CMake generate VS proj files that explicitly |
56 #set(CMAKE_ASM_MASM_COMPILE_OBJECT "<CMAKE_ASM_MASM_COMPILER> <FLAGS> /c /Fo <OBJECT> <SOURCE>") | 94 # use ml[64].exe as the assembler. |
95 enable_language(ASM) | |
96 set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "") | |
97 set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL "") | |
98 set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug "") | |
99 set(CMAKE_ASM_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL "") | |
100 set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <INCLUDES> <FLAGS> -o <OBJECT> <SOURCE>") | |
101 else() | |
102 enable_language(ASM_MASM) | |
103 | |
104 #if(CMAKE_SIZEOF_VOID_P MATCHES 8) | |
105 # set(CMAKE_ASM_COMPILER "ml64") | |
106 #else() | |
107 # set(CMAKE_ASM_COMPILER "ml") | |
108 #endif() | |
109 #set(CMAKE_ASM_COMPILER_ARG1 "/c") | |
110 #set(CMAKE_ASM_MASM_SOURCE_FILE_EXTENSIONS asm) | |
111 #set(CMAKE_ASM_MASM_COMPILE_OBJECT "<CMAKE_ASM_MASM_COMPILER> <FLAGS> /c /Fo <OBJECT> <SOURCE>") | |
112 endif() | |
57 elseif(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Intel") | 113 elseif(CMAKE_COMPILER_IS_GNUCC OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Intel") |
58 if(COMPILER_HAS_FPIC) | 114 if(COMPILER_HAS_FPIC) |
59 # when used in shared libraries, -fPIC is required by several architectures | 115 # when used in shared libraries, -fPIC is required by several architectures |
60 # and platforms (observed on AMD64, Solaris/Sparc). | 116 # and platforms (observed on AMD64, Solaris/Sparc). |
61 # we enable it per default here. | 117 # we enable it per default here. |