[cmake] use configuration generator expressions

This commit is contained in:
akallabeth
2024-11-12 09:35:32 +01:00
parent d38bf5a5e1
commit 9ac770b70e

View File

@@ -236,11 +236,10 @@ if(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wredundant-decls") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wredundant-decls")
endif() endif()
endif() endif()
if(CMAKE_BUILD_TYPE STREQUAL "Release") add_compile_definitions("$<$<CONFIG:Release>:-DNDEBUG>")
add_definitions(-DNDEBUG) add_compile_definitions("$<$<CONFIG:MinSizeRel>:-DNDEBUG>")
else() add_compile_options("$<$<CONFIG:RelWithDebInfo>:-g>")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") add_compile_options("$<$<CONFIG:Debug>:-g>")
endif()
endif() endif()
set(THREAD_PREFER_PTHREAD_FLAG TRUE) set(THREAD_PREFER_PTHREAD_FLAG TRUE)
@@ -330,11 +329,7 @@ if(MSVC)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}) set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR})
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}) set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR})
if(CMAKE_BUILD_TYPE STREQUAL "Release") add_compile_options("$<$<CONFIG:Release>:/Zi>")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Zi")
endif()
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
endif() endif()
@@ -422,15 +417,13 @@ if(ANDROID)
endif() endif()
endif() endif()
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") add_definitions("$<$<CONFIG:Debug>:-DNDK_DEBUG=1>")
add_definitions(-DNDK_DEBUG=1)
# NOTE: Manually add -gdwarf-3, as newer toolchains default to -gdwarf-4, # NOTE: Manually add -gdwarf-3, as newer toolchains default to -gdwarf-4,
# which is not supported by the gdbserver binary shipped with # which is not supported by the gdbserver binary shipped with
# the android NDK (tested with r9b) # the android NDK (tested with r9b)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_DEBUG} -gdwarf-3") add_compile_options("$<$<CONFIG:Debug>:-gdwarf-3>")
endif() add_link_options(-llog)
set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -llog")
# CMAKE_PREFIX_PATH detection is broken in most Android toolchain files # CMAKE_PREFIX_PATH detection is broken in most Android toolchain files
# Append it to CMAKE_FIND_ROOT_PATH and avoid potential duplicates # Append it to CMAKE_FIND_ROOT_PATH and avoid potential duplicates