CMakeLists: Use target_compile_options intead of add_compile_options

This commit is contained in:
MerryMage 2016-12-19 00:41:21 +00:00
parent 74a95ea51e
commit cc58666c06
3 changed files with 38 additions and 32 deletions

View file

@ -26,7 +26,8 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules)
# Compiler flags # Compiler flags
if (MSVC) if (MSVC)
add_compile_options(/W4 set(DYNARMIC_CXX_FLAGS
/W4
/w34263 # Non-virtual member function hides base class virtual function /w34263 # Non-virtual member function hides base class virtual function
/w44265 # Class has virtual functions, but destructor is not virtual /w44265 # Class has virtual functions, but destructor is not virtual
/w34456 # Declaration of 'var' hides previous local declaration /w34456 # Declaration of 'var' hides previous local declaration
@ -39,17 +40,19 @@ if (MSVC)
/Zi /Zi
/Zo /Zo
/EHsc /EHsc
/WX) /WX
add_compile_options(/DNOMINMAX) /DNOMINMAX)
if (CMAKE_VS_PLATFORM_TOOLSET MATCHES "LLVM-vs[0-9]+") if (CMAKE_VS_PLATFORM_TOOLSET MATCHES "LLVM-vs[0-9]+")
add_compile_options(-Qunused-arguments list(APPEND DYNARMIC_CXX_FLAGS
-Qunused-arguments
-Wno-unused-parameter -Wno-unused-parameter
-Wno-missing-braces) -Wno-missing-braces
add_compile_options(-Xclang -fno-operator-names) -Xclang -fno-operator-names)
endif() endif()
else() else()
add_compile_options(-Wall set(DYNARMIC_CXX_FLAGS
-Wall
-Werror -Werror
-Wextra -Wextra
-Wcast-qual -Wcast-qual
@ -57,11 +60,12 @@ else()
-pedantic-errors -pedantic-errors
-Wfatal-errors -Wfatal-errors
-Wno-unused-parameter -Wno-unused-parameter
-Wno-missing-braces) -Wno-missing-braces
add_compile_options(-fno-operator-names) -fno-operator-names)
if (ARCHITECTURE_x86_64) if (ARCHITECTURE_x86_64)
add_compile_options(-msse3) list(APPEND DYNARMIC_CXX_FLAGS
-msse3)
endif() endif()
endif() endif()

View file

@ -103,6 +103,8 @@ set_target_properties(dynarmic PROPERTIES LINKER_LANGUAGE CXX)
target_include_directories(dynarmic target_include_directories(dynarmic
PUBLIC ../include PUBLIC ../include
PRIVATE .) PRIVATE .)
target_compile_options(dynarmic PRIVATE ${DYNARMIC_CXX_FLAGS})
# Link fmt # Link fmt
target_link_libraries(dynarmic PRIVATE fmt-header-only) target_link_libraries(dynarmic PRIVATE fmt-header-only)
if (CMAKE_SYSTEM_NAME STREQUAL "Windows") if (CMAKE_SYSTEM_NAME STREQUAL "Windows")

View file

@ -37,7 +37,7 @@ create_directory_groups(${SRCS} ${HEADERS})
add_executable(dynarmic_tests ${SRCS}) add_executable(dynarmic_tests ${SRCS})
target_link_libraries(dynarmic_tests dynarmic ${llvm_libs}) target_link_libraries(dynarmic_tests dynarmic ${llvm_libs})
set_target_properties(dynarmic_tests PROPERTIES LINKER_LANGUAGE CXX) set_target_properties(dynarmic_tests PROPERTIES LINKER_LANGUAGE CXX)
target_include_directories(dynarmic_tests target_include_directories(dynarmic_tests PRIVATE . ../src)
PRIVATE . ../src) target_compile_options(dynarmic PRIVATE ${DYNARMIC_CXX_FLAGS})
add_test(dynarmic_tests dynarmic_tests) add_test(dynarmic_tests dynarmic_tests)