if(MSVC_VERSION GREATER 1699)
add_definitions(/D_ALLOW_KEYWORD_MACROS)
endif()
- add_definitions(/Dinline=__inline)
+ if(NOT USE_CLANG_CL)
+ # FIXME: Inspect
+ add_definitions(/Dinline=__inline)
+ endif()
endif()
include_directories(sdk/include/host)
# Arch Options
if(ARCH STREQUAL "i386")
- add_definitions(-D_M_IX86 -D_X86_ -D__i386__ -Di386)
+ if(NOT USE_CLANG_CL)
+ add_definitions(-D_M_IX86)
+ endif()
+ add_definitions(-D_X86_ -D__i386__ -Di386)
elseif(ARCH STREQUAL "amd64")
add_definitions(-D_M_AMD64 -D_AMD64_ -D__x86_64__ -D_WIN64)
elseif(ARCH STREQUAL "arm")
settings.c
usetup.h)
-if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
- #FIXME: Investigate Clang "illegal character encoding in string literal" warning
- set_property(SOURCE mui.c APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-invalid-source-encoding")
-endif()
-
add_executable(usetup ${SOURCE} usetup.rc)
target_link_libraries(usetup zlib inflib ext2lib vfatlib)
set_module_type(usetup nativecui)
add_pch(freeldr_common include/freeldr.h FREELDR_COMMON_SOURCE)
add_dependencies(freeldr_common bugcodes asm xdk)
+if(USE_CLANG_CL)
+ # We need to reduce the binary size
+ set_property(SOURCE ${FREELDR_BOOTLIB_COMMON_SOURCE} ${FREELDR_ARC_COMMON_SOURCE} APPEND_STRING PROPERTY COMPILE_FLAGS " /Os")
+endif()
+
if(ARCH STREQUAL "i386" AND NOT MSVC)
list(APPEND FREELDR_BASE_SOURCE arch/i386/multiboot.S)
target_link_libraries(freeldr_common mini_hal)
)
set NEW_STYLE_BUILD=1
+set USE_CLANG_CL=0
REM Parse command line parameters
:repeat
set CMAKE_GENERATOR="Eclipse CDT4 - MinGW Makefiles"
) else if /I "%1" == "Makefiles" (
set CMAKE_GENERATOR="MinGW Makefiles"
- ) else if /I "%1" == "clang" (
- set MINGW_TOOCHAIN_FILE=toolchain-clang.cmake
) else (
goto continue
)
set CMAKE_GENERATOR="Eclipse CDT4 - NMake Makefiles"
) else if /I "%1" == "Makefiles" (
set CMAKE_GENERATOR="NMake Makefiles"
+ ) else if /I "%1" == "clang" (
+ set USE_CLANG_CL=1
) else if /I "%1" == "VSSolution" (
set VS_SOLUTION=1
REM explicitly set VS version for project generator
if "%BUILD_ENVIRONMENT%" == "MinGW" (
cmake -G %CMAKE_GENERATOR% -DENABLE_CCACHE:BOOL=0 -DCMAKE_TOOLCHAIN_FILE:FILEPATH=%MINGW_TOOCHAIN_FILE% -DARCH:STRING=%ARCH% %BUILD_TOOLS_FLAG% %* "%REACTOS_SOURCE_DIR%"
+) else if %USE_CLANG_CL% == 1 (
+ cmake -G %CMAKE_GENERATOR% -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-msvc.cmake -DARCH:STRING=%ARCH% %BUILD_TOOLS_FLAG% -DUSE_CLANG_CL:BOOL=1 -DRUNTIME_CHECKS:BOOL=%VS_RUNTIME_CHECKS% %* "%REACTOS_SOURCE_DIR%"
) else (
cmake -G %CMAKE_GENERATOR% -DCMAKE_TOOLCHAIN_FILE:FILEPATH=toolchain-msvc.cmake -DARCH:STRING=%ARCH% %BUILD_TOOLS_FLAG% -DRUNTIME_CHECKS:BOOL=%VS_RUNTIME_CHECKS% %* "%REACTOS_SOURCE_DIR%"
)
add_subdirectory(fltlib)
add_subdirectory(fmifs)
add_subdirectory(fontsub)
-add_subdirectory(framedyn)
+if(NOT USE_CLANG_CL)
+ add_subdirectory(framedyn)
+endif()
add_subdirectory(fusion)
add_subdirectory(gdiplus)
add_subdirectory(getuname)
add_cd_file(TARGET browseui DESTINATION reactos/system32 FOR all)
if(NOT MSVC)
- if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
- add_target_compile_flags(browseui "-Wno-unused-but-set-variable")
- endif()
-
+ add_target_compile_flags(browseui "-Wno-unused-but-set-variable")
# Binutils linker bug
if(LTCG)
add_target_link_flags(browseui "-Wl,--allow-multiple-definition")
target_link_libraries(shellbars atlnew)
if(NOT MSVC)
- if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
- add_target_compile_flags(shellbars "-Wno-unused-but-set-variable")
- endif()
+ add_target_compile_flags(shellbars "-Wno-unused-but-set-variable")
endif()
list(APPEND SOURCE txthost.c txtsrv.c)
endif()
-if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
- #FIXME: http://llvm.org/bugs/show_bug.cgi?id=19027
- set_property(SOURCE txthost.c txtsrv.c APPEND_STRING PROPERTY COMPILE_FLAGS " -no-integrated-as")
-endif()
-
list(APPEND ADDITIONAL_SOURCE
version.rc
${CMAKE_CURRENT_BINARY_DIR}/riched20.def)
add_pch(winmm winemm.h SOURCE)
add_cd_file(TARGET winmm DESTINATION reactos/system32 FOR all)
-if((NOT MSVC) AND (NOT CMAKE_C_COMPILER_ID STREQUAL "Clang"))
+if(NOT MSVC)
add_target_compile_flags(winmm "-Wno-unused-but-set-variable")
endif()
add_library(ext2fs SHARED ${SOURCE} ext2fs.rc)
+if(USE_CLANG_CL)
+ set_property(SOURCE src/create.c src/fileinfo.c src/memory.c src/read.c APPEND_STRING PROPERTY COMPILE_FLAGS " /fallback")
+endif()
+
if(NOT MSVC)
add_target_compile_flags(ext2fs "-Wno-pointer-sign -Wno-unused-function")
- if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
- add_target_compile_flags(ext2fs "-Wno-unused-but-set-variable -Wno-unused-variable -Wno-missing-braces")
- endif()
+ add_target_compile_flags(ext2fs "-Wno-unused-but-set-variable -Wno-unused-variable -Wno-missing-braces")
else()
#disable warnings: "unreferenced local variable", "initialized, but not used variable", "benign include"
replace_compile_flags("/we\"4189\"" " ")
add_definitions(-D__KERNEL__)
set_module_type(ext2fs kernelmodedriver)
add_importlibs(ext2fs ntoskrnl hal)
-add_pch(ext2fs inc/ext2fs.h SOURCE)
+
+if(NOT USE_CLANG_CL)
+ # The fallback we have above prevents cl and clang-cl from using the same PCH
+ add_pch(ext2fs inc/ext2fs.h SOURCE)
+endif()
+
add_cd_file(TARGET ext2fs DESTINATION reactos/system32/drivers NO_CAB FOR all)
endif()
endif()
-
-if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
- #FIXME: http://llvm.org/bugs/show_bug.cgi?id=19027
- set_property(SOURCE
- ${REACTOS_SOURCE_DIR}/ntoskrnl/ke/i386/cpu.c
- ${REACTOS_SOURCE_DIR}/ntoskrnl/ke/i386/kiinit.c
- ${REACTOS_SOURCE_DIR}/ntoskrnl/ke/i386/traphdlr.c
- APPEND_STRING PROPERTY COMPILE_FLAGS " -no-integrated-as")
-endif()
endif()
if (CMAKE_COMPILER_SUPPORTS_PDBTYPE)
- set (CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "/debug /pdbtype:sept")
- set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "/debug /pdbtype:sept ${MSVC_INCREMENTAL_YES_FLAG}")
+ if(NOT USE_CLANG_CL)
+ set (CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "/debug /pdbtype:sept")
+ set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "/debug /pdbtype:sept ${MSVC_INCREMENTAL_YES_FLAG}")
+ else()
+ set(CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "/debug")
+ set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "/debug")
+ endif()
else ()
set (CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "/debug")
set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "/debug ${MSVC_INCREMENTAL_YES_FLAG}")
"Whether to compile for debugging.")
endif()
-if(MSVC)
+if(MSVC AND (NOT USE_CLANG_CL))
set(KDBG FALSE CACHE BOOL
"Whether to compile in the integrated kernel debugger.")
if(CMAKE_BUILD_TYPE STREQUAL "Release")
add_dependencies(native-${_host_tool} host-tools)
endforeach()
+if(USE_CLANG_CL)
+ # FIXME: Fix host tools build with clang
+ #set(USE_CLANG_CL_ARG "-DCMAKE_C_COMPILER=clang-cl;-DCMAKE_CXX_COMPILER=clang-cl")
+endif()
+
include(ExternalProject)
ExternalProject_Add(host-tools
BUILD_ALWAYS 1
PREFIX host-tools
EXCLUDE_FROM_ALL 1
- CMAKE_ARGS "-DNEW_STYLE_BUILD=1;-DARCH:STRING=${ARCH}"
+ CMAKE_ARGS "-DNEW_STYLE_BUILD=1;-DARCH:STRING=${ARCH};${USE_CLANG_CL_ARG}"
INSTALL_COMMAND ""
BUILD_BYPRODUCTS ${tools_binaries})
add_definitions(/Dinline=__inline /D__STDC__=1)
-add_compile_flags("/X /GR- /EHs-c- /GS- /Zl /W3")
+if(NOT USE_CLANG_CL)
+ add_compile_flags("/X /Zl")
+endif()
+
+add_compile_flags("/GR- /EHs-c- /GS- /W3")
+
+if(USE_CLANG_CL)
+ set(CMAKE_CL_SHOWINCLUDES_PREFIX "Note: including file: ")
+endif()
# HACK: for VS 11+ we need to explicitly disable SSE, which is off by
# default for older compilers. See CORE-6507
# - C4115: named type definition in parentheses
add_compile_flags("/w14115")
+if(USE_CLANG_CL)
+ add_compile_flags_language("-nostdinc -Wno-multichar -Wno-char-subscripts -Wno-microsoft-enum-forward-reference -Wno-pragma-pack -Wno-microsoft-anon-tag -Wno-unknown-pragmas" "C")
+ add_compile_flags_language("-nostdinc -Wno-multichar -Wno-char-subscripts -Wno-microsoft-enum-forward-reference -Wno-pragma-pack -Wno-microsoft-anon-tag -Wno-unknown-pragmas" "CXX")
+endif()
+
# Debugging
#if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
# Hotpatchable images
if(ARCH STREQUAL "i386")
- add_compile_flags("/hotpatch")
+ if(NOT USE_CLANG_CL)
+ add_compile_flags("/hotpatch")
+ endif()
set(_hotpatch_link_flag "/FUNCTIONPADMIN:5")
elseif(ARCH STREQUAL "amd64")
set(_hotpatch_link_flag "/FUNCTIONPADMIN:6")
add_definitions(/DLANGUAGE_EN_US)
else()
# Only VS 10+ resource compiler supports /nologo
- if(MSVC_VERSION GREATER 1599)
+ # CMAKE_CXX_SIMULATE_VERSION is a similar check for our clang-cl builds
+ if((MSVC_VERSION GREATER 1599) OR (CMAKE_CXX_SIMULATE_VERSION VERSION_GREATER 15.99))
set(rc_nologo_flag "/nologo")
else()
set(rc_nologo_flag)
set(_pch_path_name_flag "/Fp${_gch}")
endif()
+ if(USE_CLANG_CL)
+ set(_pch_compile_flags "${_cl_lang_flag} /Yc${_pch} /FI${_pch} /Fp${_gch}")
+ else()
+ set(_pch_compile_flags "${_cl_lang_flag} /Yc /Fp${_gch}")
+ endif()
+
# Build the precompiled header
# HEADER_FILE_ONLY FALSE: force compiling the header
set_source_files_properties(${_pch} PROPERTIES
HEADER_FILE_ONLY FALSE
LANGUAGE ${_pch_language}
- COMPILE_FLAGS "${_cl_lang_flag} /Yc /Fp${_gch}"
+ COMPILE_FLAGS ${_pch_compile_flags}
OBJECT_OUTPUTS ${_gch})
# Prevent a race condition related to writing to the PDB files between the PCH and the excluded list of source files
set_source_files_properties(${CRT_ASM_SOURCE} PROPERTIES COMPILE_DEFINITIONS "__MINGW_IMPORT=extern;USE_MSVCRT_PREFIX;_MSVCRT_LIB_;_MSVCRT_;_MT;CRTDLL")
add_asm_files(crt_asm ${CRT_ASM_SOURCE})
-if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
- #FIXME: http://llvm.org/bugs/show_bug.cgi?id=19027
- set_property(SOURCE except/cpp.c APPEND_STRING PROPERTY COMPILE_FLAGS " -no-integrated-as")
+if(USE_CLANG_CL)
+ # clang-cl is missing pragma function support
+ # https://bugs.llvm.org/show_bug.cgi?id=35116
+ set_property(SOURCE stdlib/rot.c APPEND_STRING PROPERTY COMPILE_FLAGS " /fallback")
endif()
add_library(crt ${CRT_SOURCE} ${crt_asm})
set(_pp_asm16_compile_command ${CMAKE_ASM16_COMPILER} /nologo /Cp /Fo${_object_file} /c /Ta ${_preprocessed_asm_file})
endif()
+ # FIXME: clang-cl can't compile this so use cl here instead of ${CMAKE_C_COMPILER} in the meantime
add_custom_command(
OUTPUT ${_preprocessed_asm_file} ${_object_file}
- COMMAND ${CMAKE_C_COMPILER} /nologo /X /I${REACTOS_SOURCE_DIR}/sdk/include/asm /I${REACTOS_BINARY_DIR}/sdk/include/asm ${_directory_includes} ${_source_file_defines} ${_directory_defines} /D__ASM__ /D_USE_ML /EP /c ${_concatenated_asm_file} > ${_preprocessed_asm_file} && ${_pp_asm16_compile_command}
+ COMMAND cl /nologo /X /I${REACTOS_SOURCE_DIR}/sdk/include/asm /I${REACTOS_BINARY_DIR}/sdk/include/asm ${_directory_includes} ${_source_file_defines} ${_directory_defines} /D__ASM__ /D_USE_ML /EP /c ${_concatenated_asm_file} > ${_preprocessed_asm_file} && ${_pp_asm16_compile_command}
DEPENDS ${_concatenated_asm_file})
add_custom_command(
set(CMAKE_SYSTEM_PROCESSOR i686)
# which compilers to use for C and C++
-set(CMAKE_C_COMPILER cl)
+if(USE_CLANG_CL)
+ set(CMAKE_C_COMPILER clang-cl)
+else()
+ set(CMAKE_C_COMPILER cl)
+endif()
if(ARCH STREQUAL "arm")
include(CMakeForceCompiler)
CMAKE_FORCE_CXX_COMPILER(cl MSVC)
else()
-set(CMAKE_CXX_COMPILER cl)
+ if(USE_CLANG_CL)
+ set(CMAKE_CXX_COMPILER clang-cl)
+ else()
+ set(CMAKE_CXX_COMPILER cl)
+ endif()
endif()
set(CMAKE_MC_COMPILER mc)