cglm icon indicating copy to clipboard operation
cglm copied to clipboard

cl: Command line warning D9025

Open Eric-Arz opened this issue 4 years ago • 5 comments
trafficstars

I am having problems integrating the clgm source code into a larger cmake project on Windows. cl.exe complains about warning & optimizations levels getting overridden by the clgm CMakeLists.txt.

This is what causes the issue:

if(MSVC)
  add_definitions(-DNDEBUG -D_WINDOWS -D_USRDLL)
  add_compile_options(/W3 /Ox /Gy /Oi /TC)
  
  # Ref: https://skia.googlesource.com/third_party/sdl/+/refs/heads/master/CMakeLists.txt#225
  # Make sure /RTC1 is disabled, otherwise it will use functions from the CRT
  foreach(flag_var
      CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
      CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
    string(REGEX REPLACE "/RTC(su|[1su])" "" ${flag_var} "${${flag_var}}")
  endforeach(flag_var)
else()
  add_compile_options(-Wall -Werror -O3)
endif()

In particular:

add_definitions(-DNDEBUG -D_WINDOWS -D_USRDLL) add_compile_options(/W3 /Ox /Gy /Oi /TC)

Is there any reason why you are setting those flags for all targets instead of using target_compile_options? For now i just removed those lines as a temporary solution.

Eric-Arz avatar Sep 11 '21 13:09 Eric-Arz

Hi @Eric-Arz

Thanks for reporting this,

cl.exe complains about warning & optimizations levels getting overridden by the clgm CMakeLists.txt.

Can you share some of warnings & errors?

Is there any reason why you are setting those flags for all targets instead of using target_compile_options? For now i just removed those lines as a temporary solution.

IIRC, the reason is to enable optimizations on cglm library, not on any other targets, otherwise it is a build-bug and must be fixed...

Also if you only use inline versions you don't have to build cglm, follow https://github.com/recp/cglm#use-as-header-only-library-with-your-cmake-project


recp avatar Sep 11 '21 19:09 recp

@recp For example cl : Command line warning D9025 : overriding '/Od' with '/Ox'. when building the project as a debug build.

Eric-Arz avatar Sep 12 '21 10:09 Eric-Arz

@Eric-Arz thanks for sharing this, I'll investigate this. Any idea would be awesome about what is wrong in cglm's build configuration and in yours maybe ...

recp avatar Sep 12 '21 21:09 recp

@recp I just used add_subdirectory(lib/cglm) alongside target_link_libraries(${PROJECT_NAME} PRIVATE cglm) to integrate cglm.

I think the issue is using add_compile_options() in clgm's CMakeLists.txt which overrides all settings that are set by the root CMakeLists.txt (or by default / IDE, i actually didn't explicitly set anything).

Eric-Arz avatar Sep 16 '21 13:09 Eric-Arz

@Eric-Arz thanks,

Any idea how to fix it? If the cglm is compiled separately these options must appear to optimize the library, but we can improve CMake build conf for integrating existing project, maybe we can add these options conditionally by checking a variable and if the variable; let's say CGLM_SKIP_COMPILE_OPTIOS... is defined then build could skip these options maybe, I'm not sure for best solution for now, any help would be appreciated

recp avatar Sep 16 '21 20:09 recp