Commit graph

58 commits

Author SHA1 Message Date
Serge Gautherie 51e2ab52af [CMAKE] msvc.cmake: Add arm64 CMAKE_ASM_MASM_COMPILER option support
CORE-17518
2021-10-11 15:24:30 +03:00
Victor Perevertkin 8e1fa03456
[CMAKE] Replace custom scripts in compilerflags with standard ones
- add_target_link_flags changed to target_link_options
- add_target_property changed to set_property(... APPEND ...)
2021-09-14 17:56:22 +03:00
Victor Perevertkin 5176f580e5
[CMAKE] Add memcmp to libntoskrnl for both clang and clang-cl 2021-08-02 20:23:22 +03:00
Timo Kreuzer cb9b538725 [CMAKE] Turn all warnings into errors on MSVC x86 2021-07-23 22:03:48 +02:00
Timo Kreuzer f4de12e9f4 [CMAKE] Don't turn C4101 (unreferenced local variable) into an error on release builds 2021-07-11 21:45:29 +02:00
Jérôme Gardou aa51bcfbcb [CMAKE] Do not use a flag which clang doesn't know 2021-05-03 22:00:57 +02:00
Victor Perevertkin d10728a645
[CMAKE] Rely less on CMAKE_BUILD_TYPE variable
Having conditional statements with CMAKE_BUILD_TYPE is an antipattern
See https://stackoverflow.com/questions/66079007/having-conditional-statements-on-build-type-variable-a-good-design

We use both single- and multi-config generators (Ninja and VS), so we
can't really rely on CMAKE_BUILD_TYPE, because it's not always set.

This commit alters some conditional flags to use <$CONFIG:...>
generator expression, but is still not complete. Also, our default
optimization level (4) now has what was always a de-facto flags
2021-04-15 06:44:56 +03:00
Jérôme Gardou f5bace8536 [CMAKE] Move toolchain specific handling to set_module_type_toolchain
+ style fixes
2021-03-23 11:18:43 +01:00
Jérôme Gardou e55123a6a2 [CMAKE] Add the kernel module type
Take this as an occasion to use target_link_options more
2021-03-23 11:18:43 +01:00
Jérôme Gardou c68739e566 [CMAKE] Preprocess the ASM files but let msbuild handle their actual compilation
CORE-17423
2021-03-03 08:34:32 +01:00
Jérôme Gardou 41130ab5c6 [CMAKE] Use ASM_MASM language when building with MSVC toolchain
CORE-17423
2021-03-03 08:34:32 +01:00
Victor Perevertkin e394a1312a
[CMAKE] Replace CMAKE_AR with CMAKE_LINKER /LIB for msvc
Render the command to a variable for dealing with quotes properly

Addendum to ca1b2ada34 and b96e88894a
2021-01-03 04:06:51 +03:00
Victor Perevertkin ca1b2ada34
[CMAKE] Replace DIVISION_SLASH unicode character with SOLIDUS
This fixes the build on some machines. In addition, replace
the hardcoded "LINK /LIB" with ${CMAKE_AR}

Addendum to b96e88894a
2021-01-03 03:46:12 +03:00
Jérôme Gardou b96e88894a [CMAKE] Turn import libs into regular C static libs
Embed msvcrtex into libmsvcrt

Idea taken from Thomas Faber
2020-12-28 12:13:30 +01:00
Jérôme Gardou 56e56f8ecc [CMAKE] Use -fcommon when using CLang 2020-12-28 12:13:30 +01:00
Victor Perevertkin 658f742c2d
[NDK][CMAKE] Introduce DATA_SEG and CODE_SEG macro
These are for putting code and data to non-default sections
At the same time, move INIT section attributes declaration to cmake files
2020-11-02 21:27:06 +03:00
Timo Kreuzer d685dcee9b [CMAKE] Rename def files for import libraries on MSVC builds to *_implib.de like on GCC 2020-11-01 09:33:14 +01:00
Jérôme Gardou 00ed72d7e8 [CMAKE] Get rid of add_compile_flags
Use add_compile_options and the like instead
2020-10-20 21:44:54 +02:00
Jérôme Gardou ed61512236 [CMAKE] Get rid of add_compile_flags_language macro
in favor of add_compile_options and the like with generator expressions
Also take this as an opportunity to remove the C++11 standard hack, GCC 8 now defaults to C++14
2020-10-20 21:44:54 +02:00
Jérôme Gardou 7e116f0ef3 [CMAKE] Get rid of replace_compile_flags
Introduce a finer-grained remove_target_compile_option instead
2020-10-20 21:44:54 +02:00
Jérôme Gardou d6ea8659c8 [CMAKE] Get rid of the set_cpp macro
Instead of messing with global variables and the like, we introduce two target properties:
 - WITH_CXX_EXCEPTIONS: if you want to use C++ exceptions
 - WITH_CXX_RTTI: if you need RTTI in your module
You can use the newly introduced set_target_cpp_properties function, with WITH_EXCEPTIONS and WITH_RTTI arguments
We also introduce two libraries :
 - cpprt: for C++ runtime routines
 - cppstl: for the C++ standard template library

NB: On GCC, this requires to create imported libraries with the related built-in libraries:libsupc++, limingwex, libstdc++

Finally, we manage the relevant flags with the ad-hoc generator expressions

So, if you don't need exceptions, nor RTTI, nor use any runtime at all: you simply have nothing else to do than add your C++ file to your module
2020-10-20 21:44:54 +02:00
Mark Jansen 5730485a51 [SDK] Add dummy import lib files for MSVC_IDE build,
to work around a CMake bug generating broken dll targets
ROSBE-159
2020-09-20 19:18:15 +02:00
Thomas Faber a81788e5bf
[CMAKE] Explicitly target Pentium for clang. CORE-17202
The MSVC-compatible /arch:IA32 option switches to i386 mode, which
makes clang avoid 486/Pentium-specific instructions, e.g. cmpxchg8b.
2020-08-23 12:07:37 +02:00
Thomas Faber 8275c1f991
[CMAKE] Use a space after /fo for the RC compiler to make clang happy. CORE-17202 2020-08-23 12:07:37 +02:00
Thomas Faber dd6eb40381
[CMAKE] Remove work-arounds for old CMake versions. CORE-17109 2020-06-20 15:25:29 +02:00
Thomas Faber add677e45b
[CMAKE] Bump minimum to 3.17, no longer require -ReactOS build. CORE-17109 2020-06-20 15:25:28 +02:00
Thomas Faber 3169c94e06
[CMAKE] Set CMAKE_MSVC_RUNTIME_LIBRARY to satisfy CMP0091. CORE-17109
We use /NODEFAULTLIB, and consequently also don't want CMake to add
a default library for us.
2020-06-20 15:25:27 +02:00
Amine Khaldi 139a3d6661
[CMAKE] Implement PCH builds with target_precompile_headers. CORE-16905 2020-06-06 21:58:41 +03:00
Serge Gautherie 11345aedd8
[FORMATTING] [CMAKE] Remove space in 'if (' (#2847) 2020-05-26 20:24:02 +02:00
Victor Perevertkin 156b3bd014
[REACTOS] Drop support for Visual Studio below 2015 2020-05-04 21:47:37 +03:00
Mark Jansen 0b948581fc
[SDK][HOST-TOOLS] Add load_config workaround for gcc builds
Since binutils can not add this, we re-introduce pefixup.
It searches for the exported symbol '_load_config_used',
and uses that to fill out the LOAD_CONFIG directory in the PE header
2020-04-17 17:47:24 +02:00
Victor Perevertkin 92dfec219d
[CMAKE][CONFIGURE] Enable runtime checks on MSVC by default.
Remove RTC switch from configure.cmd, now MSVC runtime checks are
supposed to be enabled/disabled via CMake define (-DRUNTIME_CHECKS=1)
Prepare for adding more dynamic analysis options
2020-04-11 02:48:12 +03:00
Hermès Bélusca-Maïto 93beefacbe
[CMAKE][FREELDR] Take the global defines into account when compiling ASM files.
Now the SARCH_xxx can be used in ASM files too.
Dedicated to Dmitry Borisov ;)
2020-03-06 22:55:12 +01:00
Thomas Faber 11ecf5c969
[CMAKE] Enable C4101 (unreferenced local variable) for MSVC builds.
This is already an error in GCC builds, so will make it harder for the
MSVC crowd to accidentally break GCC build.
2020-02-24 11:01:43 +01:00
Timo Kreuzer 0ff3bb904b [CMAKE] Turn printf format warnings (C4313 and C4477) into errors 2019-11-24 09:28:00 +01:00
Timo Kreuzer 70bcd0fc6b [CMAKE] Disable EH4 for x64 and VS versions 16.3+
This fixes x64 build with latest VS 2019
See https://developercommunity.visualstudio.com/content/problem/746534/visual-c-163-runtime-uses-an-unsupported-api-for-u.html
2019-11-24 09:26:59 +01:00
Timo Kreuzer 767d424b0a [CMAKE] Turn C4715: "'function': not all control paths return a value" into an error on MSVC builds 2019-08-23 14:47:39 +02:00
Thomas Faber c4d8e2a6e9
[CMAKE] Ensure the INIT section is placed at the end of a module. CORE-14683
For MSVC, marking the section as discardable will do this automatically.
For GCC, we use a linker script that places it after the .reloc section
(which should be the last "real" section, check ld --verbose output for the
default linker script).

This fixes what seems to be a regression from r55835 (!).
2019-07-07 08:18:10 +02:00
Timo Kreuzer fad4b34db7 [CMAKE] Fix LINK_DEPENDS usage
Up to CMake 3.3 LINK_DEPENDS was ignored in non-Makefile generators. See also http://www.cmake.org/pipermail/cmake/2010-May/037206.html. Since CMake 3.4 it is no longer ignored, but requires CMP0005 policy to be set to NEW and it requires a full path which was already correctly used on GCC, but not on MSVC builds.
2019-04-27 14:29:33 +02:00
Serge Gautherie 9f3eb1f9a2 [CMAKE] msvc.cmake: Remove now redundant '/we4028' special case
Addendum to 545a2c7936.

CORE-7538
2019-04-19 20:47:03 +02:00
Timo Kreuzer 545a2c7936 [CMAKE] Add 3 more critical warnings for MSVC
- C4311: pointer truncation from '<pointer>' to '<integer>'
- C4312: conversion from '<integer>' to '<pointer>' of greater size
- C4133: incompatible types - from '<x> *' to '<y> *'
- C4028: formal parameter different from declaration
2019-04-13 14:07:50 +02:00
Jérôme Gardou 23373acbb9 [CMAKE] Use modules instead of shared libraries
There is no need to compile our DLLs as shared libraries since we are
managing symbols exports and imports through spec files.

On my system, this reduces the configure-time by a factor of two.
2019-04-06 17:43:38 +02:00
Serge Gautherie 237110604b [CMAKE] msvc.cmake: Remove 2 now redundant '/GF' (#1239)
Addendum to 5e673f3.
CORE-14373
2019-02-10 16:46:23 +01:00
Hermès Bélusca-Maïto 1b473cbeee
[SDK:CMAKE] Fix LINK command-line from the VS IDE for CMake VSSolution configurations, when using MSVC "linker script" files.
MSBuild, via the VS IDE, uses response files when calling CL or LINK.
We cannot specify a custom response file on the linker command-line,
since specifying response files from within response files is forbidden.
We therefore have to pre-process, at configuration time, the linker
script so as to retrieve the custom linker options to be appended
to the linker command-line.
2019-02-10 00:47:43 +01:00
Hermès Bélusca-Maïto 7d0cd6e937
[FREELDR][SDK:CMAKE] Move the `MSVC "linker script" file' functionality out of FreeLdr's cmake file and place it in the dedicated files instead. 2019-02-10 00:43:31 +01:00
Hermès Bélusca-Maïto 5e673f3118
[CMAKE] MSVC cmake settings improvements.
- Always use string pooling when building: this helps reducing the
  size of the binaries due to string redundancy coming from the usage
  of __FILE__ / __RELFILE__ in the debugging helper macros. Note also
  that GCC builds use string pooling by default.

- Use suitable add_compile_flags() command.
- Add some explanative comments for some settings.

Some numbers (obtained with my local builds):

Before / After => Reduction
===========================

freeldr.sys  :  443 KB (  453.632 bytes) /  364 KB (  372.736 bytes) => ~ 18%
win32k.sys   : 1877 KB (1.922.048 bytes) / 1562 KB (1.599.488 bytes) => ~ 17%
ntoskrnl.exe : 2253 KB (2.307.072 bytes) / 1902 KB (1.947.136 bytes) => ~ 15.6%
kernel32.dll : 3008 KB (3.080.192 bytes) / 2906 KB (2.975.744 bytes) => ~ 3.4%
2019-01-12 18:09:51 +01:00
Timo Kreuzer 71fefa32db
[NDK][NTOS] Add global definition of INIT_FUNCTION/INIT_SECTION (#779)
* Add an NDK header to define INIT_FUNCTION/INIT_SECTION globally
* Use _declspec(allocate(x)) and _declspec(code_seg(x)) on MSVC versions that support it
* Use INIT_FUNCTION on functions only and INIT_SECTION on data only (required by MSVC)
* Place INIT_FUNCTION before the return type (required by MSVC)
* Make sure declarations and implementations share the same modifiers (required by MSVC)
* Add a global linker option to suppress warnings about defined but unused INIT section
* Merge INIT section into .text in freeldr
2018-12-30 12:19:11 +01:00
Serge Gautherie d840d7cb1b [CMAKE] MSVC: Make C4028 warning into error, on "i386" only
"C4028: formal parameter N different from declaration"

CORE-7538
2018-12-16 23:12:22 +01:00
Mark Jansen b494abbd72
[SDK] Add version option to our spec2def cmake command 2018-10-12 19:30:36 +02:00
Mark Jansen 4e3f76352a
[SDK] Add the WITH_RELAY option to msvc's spec2def command. (GCC already had it) 2018-10-12 19:30:35 +02:00