-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update windows.cmake to fix common build issues on Windows #984
Conversation
* Avoid using set_target_properties on ALIAS targets This change is to fix the error like below: 2018-11-30T10:40:39.7610068Z CMake Error at C:/opt/ros/melodic/x64/share/catkin/cmake/platform/windows.cmake:47 (set_target_properties): 2018-11-30T10:40:39.7610963Z set_target_properties can not be used on an ALIAS target. 2018-11-30T10:40:39.7611263Z Call Stack (most recent call first): 2018-11-30T10:40:39.7611903Z abseil_cpp/CMake/AbseilHelpers.cmake:67 (add_library) 2018-11-30T10:40:39.7612185Z abseil_cpp/absl/base/CMakeLists.txt:74 (absl_library) * nit
) Walking through the projects we touched for ROS, many of them simply are just missing the dllimport/dllexport declarative, so no imported library is generated and breaks the build for downstream projects. Some are fixed by defining dllexport/dllimport, by defining WINDOWS_EXPORT_ALL_SYMBOLS, or by switching them to STATIC library (STATIC lib sometimes even creates more problems since the author assumes it is a shared lib at run-time). In order to quickly enabling more untouched ROS packages, I am suggesting to enable CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS globally to quickly enabling them, but we should still encourage the package owners to explicitly use dllexport in our cookbook.
While I am not a big fan of working around the various definitions globally within Thank you for the patch. |
Thanks a lot for your understanding! Hopefully this kind of change could be eventually removed from the global build tool ( |
while building on Windows, it's not uncommon to encounter various platform-specific issues and compiler-specific issues (if using visual c++ compiler, MSVC).
For the debug flags and compiler options, a lot of these issues are already known to the community, and most of them could be resolved with existing good practices:
-DNOMINMAX
helps avoid collision withstd::min
/std::max
if there'swindows.h
/windef.h
-DNO_STRICT
(and-DQ_NOWINSTRICT
for QT) disables STRICT type checking-D_USE_MATH_DEFINES
allows using Math Constants since they are not defined in Standard C/C++-DWIN32_LEAN_AND_MEAN
excludes various APIs from windows.h to improve build time since basic inclusion would be enough