From d5d176d1a503f5382ed147158c9f8b0ed849c356 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 6 Sep 2019 07:50:15 -0400 Subject: [PATCH] visigen/CMakeLists: Modify target directly Instead of using variables, we can directly specify our requirements on the target instance directly. This also avoids modifying CMAKE_CXX_FLAGS. --- visigen/CMakeLists.txt | 44 +++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/visigen/CMakeLists.txt b/visigen/CMakeLists.txt index 2e5853313..da13fffd9 100644 --- a/visigen/CMakeLists.txt +++ b/visigen/CMakeLists.txt @@ -5,33 +5,51 @@ project(visigen) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_executable(visigen + VISIBuilder.cpp + VISIBuilder.hpp + VISIRenderer.cpp + VISIRenderer.hpp +) + if(MSVC) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") + target_compile_options(visigen PRIVATE /EHsc) else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}\ - -Wno-multichar -fno-exceptions -Wno-narrowing -Wno-nullability-completeness -Werror=return-type") + target_compile_options(visigen PRIVATE + -fno-exceptions + + -Werror=return-type + -Wno-multichar + -Wno-narrowing + -Wno-nullability-completeness + ) endif() if(APPLE) - set(PLAT_SRCS MainMac.mm) + target_sources(visigen PRIVATE MainMac.mm) set_source_files_properties(MainMac.mm PROPERTIES COMPILE_FLAGS -fobjc-arc) elseif(WIN32) - set(PLAT_SRCS MainWin.cpp) + target_sources(visigen PRIVATE MainWin.cpp) else() - set(PLAT_SRCS MainXlib.cpp) + target_sources(visigen PRIVATE MainXlib.cpp) endif() -add_executable(visigen ${PLAT_SRCS} - VISIRenderer.cpp VISIRenderer.hpp - VISIBuilder.cpp VISIBuilder.hpp) - set_target_properties(visigen PROPERTIES COMPILE_DEFINITIONS URDE_DLPACKAGE="${URDE_DLPACKAGE}") if(APPLE) find_library(OPENGL_LIBRARY OpenGL) - set(PLAT_LIBS ${OPENGL_LIBRARY}) + target_link_libraries(visigen PRIVATE ${OPENGL_LIBRARY}) endif() -target_link_libraries(visigen logvisor athena-core zeus glew - xxhash ${ZLIB_LIBRARIES} lzokay hecl-light ${PLAT_LIBS}) +target_link_libraries(visigen PRIVATE + athena-core + glew + hecl-light + logvisor + lzokay + xxhash + zeus + ${ZLIB_LIBRARIES} +) endif()