Skip to content
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

cmake: a few fixes for multi-config generators #2357

Merged
merged 8 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,20 @@ macro(set_var_to_condition var)
endif()
endmacro()

get_property(MIOPEN_GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)

# This has to be initialized before the project() command appears
# Set the default of CMAKE_BUILD_TYPE to be release, unless user specifies with -D. MSVC_IDE does not use CMAKE_BUILD_TYPE
if( NOT MSVC_IDE AND NOT CMAKE_BUILD_TYPE )
set( CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." )
# Set the default of CMAKE_BUILD_TYPE to be release, unless user specifies with -D.
if(MIOPEN_GENERATOR_IS_MULTI_CONFIG)
if (NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release;RelWithDebInfo;MinSizeRel" CACHE STRING
"Available build types (configurations) on multi-config generators")
endif()
else()
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel.")
endif()
endif()

# Default installation path
Expand Down Expand Up @@ -254,8 +264,7 @@ endif()

message(STATUS "Hip compiler flags: ${HIP_COMPILER_FLAGS}")

add_definitions("-DHIP_COMPILER_FLAGS=${HIP_COMPILER_FLAGS}")

add_compile_definitions($<$<COMPILE_LANGUAGE:CXX>:HIP_COMPILER_FLAGS="${HIP_COMPILER_FLAGS}">)
Copy link
Contributor

@atamazov atamazov Nov 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@apwojcik 🐛 These extra double ticks break HIP kernel builds on offline path (-DMIOPEN_USE_COMGR=Off -DMIOPEN_USE_HIPRTC=Off), and, possibly, on COMgr path (-DMIOPEN_USE_HIPRTC=Off), thus affecting Tuna. Fix TBD soon.

/cc @JehandadKhan @junliume

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in #2544


# HIP
if( MIOPEN_BACKEND STREQUAL "HIP" OR MIOPEN_BACKEND STREQUAL "HIPOC" OR MIOPEN_BACKEND STREQUAL "HIPNOGPU")
Expand Down
183 changes: 99 additions & 84 deletions cmake/EnableCompilerWarnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,89 +26,104 @@
# - Enable warning all for gcc/clang or use /W4 for visual studio

## Strict warning level
if (MSVC)
# Use the highest warning level for visual studio.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /w")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /w")
# set(CMAKE_CXX_WARNING_LEVEL 4)
# if (CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
# string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
# else ()
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
# endif ()
set(__msvc_cxx_compile_options /W4)

# set(CMAKE_C_WARNING_LEVEL 4)
# if (CMAKE_C_FLAGS MATCHES "/W[0-4]")
# string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
# else ()
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W4")
# endif ()
set(__default_cxx_compile_options
-Wall
-Wextra
-Wcomment
-Wendif-labels
-Wformat
-Winit-self
-Wreturn-type
-Wsequence-point
-Wswitch
-Wtrigraphs
-Wundef
-Wuninitialized
-Wunreachable-code
-Wunused
-Wno-ignored-qualifiers
-Wno-sign-compare
)

else()
foreach(COMPILER C CXX)
set(CMAKE_COMPILER_WARNINGS)
# use -Wall for gcc and clang
list(APPEND CMAKE_COMPILER_WARNINGS
-Wall
-Wextra
-Wcomment
-Wendif-labels
-Wformat
-Winit-self
-Wreturn-type
-Wsequence-point
# Shadow is broken on gcc when using lambdas
# -Wshadow
-Wswitch
-Wtrigraphs
-Wundef
junliume marked this conversation as resolved.
Show resolved Hide resolved
-Wuninitialized
-Wunreachable-code
-Wunused
-Wno-ignored-qualifiers
-Wno-sign-compare
)
if (CMAKE_${COMPILER}_COMPILER_ID MATCHES "Clang")
list(APPEND CMAKE_COMPILER_WARNINGS
-Weverything
-Wno-c++98-compat
-Wno-c++98-compat-pedantic
-Wno-conversion
-Wno-double-promotion
-Wno-exit-time-destructors
-Wno-extra-semi
-Wno-extra-semi-stmt
-Wno-float-conversion
-Wno-gnu-anonymous-struct
-Wno-gnu-zero-variadic-macro-arguments
-Wno-missing-prototypes
-Wno-nested-anon-types
-Wno-option-ignored
-Wno-padded
-Wno-return-std-move-in-c++11
-Wno-shorten-64-to-32
-Wno-sign-conversion
-Wno-unknown-warning-option
-Wno-unused-command-line-argument
-Wno-weak-vtables
-Wno-covered-switch-default
-Wno-unused-result
-Wno-unsafe-buffer-usage
-Wno-deprecated-declarations
-Wno-shadow-uncaptured-local
)
else()
if (CMAKE_${COMPILER}_COMPILER_ID MATCHES "GNU" AND ${COMPILER} MATCHES "CXX")
# cmake 3.5.2 does not support >=.
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.1")
list(APPEND CMAKE_COMPILER_WARNINGS
-Wno-ignored-attributes)
endif()
endif()
list(APPEND CMAKE_COMPILER_WARNINGS
-Wno-missing-field-initializers
)
endif()
add_definitions(${CMAKE_COMPILER_WARNINGS})
endforeach()
endif ()
set(__clang_cxx_compile_options
-Weverything
-Wno-c++98-compat
-Wno-c++98-compat-pedantic
-Wno-conversion
-Wno-double-promotion
-Wno-exit-time-destructors
-Wno-extra-semi
-Wno-extra-semi-stmt
-Wno-float-conversion
-Wno-gnu-anonymous-struct
-Wno-gnu-zero-variadic-macro-arguments
-Wno-missing-prototypes
-Wno-nested-anon-types
-Wno-option-ignored
-Wno-padded
-Wno-return-std-move-in-c++11
-Wno-shorten-64-to-32
-Wno-sign-conversion
-Wno-unknown-warning-option
-Wno-unused-command-line-argument
-Wno-weak-vtables
-Wno-covered-switch-default
-Wno-unused-result
-Wno-unsafe-buffer-usage
-Wno-deprecated-declarations
-Wno-shadow-uncaptured-local
-Wno-global-constructors
-Wno-reserved-identifier
-Wno-zero-as-null-pointer-constant
-Wno-ignored-attributes
-Wno-deprecated
-Wno-incompatible-pointer-types
-Wno-old-style-cast
-Wno-unknown-attributes
-Wno-microsoft-cpp-macro
-Wno-microsoft-enum-value
-Wno-language-extension-token
-Wno-c++11-narrowing
-Wno-float-equal
-Wno-redundant-parens
-Wno-format-nonliteral
-Wno-unused-template
-Wno-comma
-Wno-suggest-destructor-override
-Wno-switch-enum
-Wno-shift-sign-overflow
-Wno-suggest-override
-Wno-inconsistent-missing-destructor-override
-Wno-cast-function-type
-Wno-nonportable-system-include-path
-Wno-incompatible-pointer-types
-Wno-documentation
-Wno-deprecated-builtins
-Wno-enum-constexpr-conversion
-Wno-unused-value
-Wno-unused-parameter
-Wno-missing-noreturn
-Wno-tautological-constant-out-of-range-compare)
if(WIN32)
list(APPEND __clang_cxx_compile_options
-fdelayed-template-parsing
-fms-extensions
-fms-compatibility)
endif()

set(__gnu_cxx_compile_options
-Wno-missing-field-initializers
)

add_compile_options(
"$<$<CXX_COMPILER_ID:MSVC>:${__msvc_cxx_compile_options}>"
"$<$<CXX_COMPILER_ID:Clang>:${__default_cxx_compile_options};${__clang_cxx_compile_options}>"
"$<$<CXX_COMPILER_ID:GNU>:${__default_cxx_compile_options};${__gnu_cxx_compile_options}>"
)
Comment on lines +120 to +124
Copy link
Contributor

@atamazov atamazov Nov 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Recommendation] @apwojcik This should work, but please double-check correctness of this.


unset(__msvc_cxx_compile_options)
unset(__default_cxx_compile_options)
unset(__gnu_cxx_compile_options)
unset(__clang_cxx_compile_options)
4 changes: 3 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ configure_file( "${PROJECT_SOURCE_DIR}/include/miopen/miopen.h" "${PROJECT_BINAR
endif()

message( STATUS "MIOpen_VERSION= ${MIOpen_VERSION}" )
message( STATUS "CMAKE_BUILD_TYPE= ${CMAKE_BUILD_TYPE}" )
if(NOT MIOPEN_GENERATOR_IS_MULTI_CONFIG)
message( STATUS "CMAKE_BUILD_TYPE= ${CMAKE_BUILD_TYPE}" )
endif()

# This is incremented when the ABI to the library changes
set( MIOpen_SOVERSION 1.0 )
Expand Down
12 changes: 5 additions & 7 deletions src/sqlite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ add_library(
OBJECT
memvfs.cpp
)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# using Clang
set_source_files_properties(memvfs.cpp PROPERTIES COMPILE_FLAGS "-Wno-everything ")
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# using GCC
set_source_files_properties(memvfs.cpp PROPERTIES COMPILE_FLAGS "-w ")
endif()

target_compile_options(sqlite_memvfs PRIVATE
$<$<CXX_COMPILER_ID:Clang>:-Wno-everything>
$<$<CXX_COMPILER_ID:GNU>:-w>)
junliume marked this conversation as resolved.
Show resolved Hide resolved

target_include_directories(sqlite_memvfs SYSTEM PRIVATE ${SQLITE3_STATIC_INCLUDE_DIRS})
# set_target_properties(
# sqlite_memvfs
Expand Down