From 05b542182ac15c97449ca1be1a291ebf0ed9def5 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 3 Jun 2016 17:30:00 -0400 Subject: [PATCH] More cmake stuff. MSVC shared builds work as we want them to so far (mostly). --- CMakeLists.txt | 22 +++++++++++++++++++--- migrate_build/CMakeLists.txt | 3 --- test/CMakeLists.txt | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 test/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 5cf2e587..e8507cc8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,11 @@ if(APPLE) set(_OSNAME darwin) elseif(WIN32) set(_OSNAME windows) + + # and don't include the default libraries with ANY of the builds + # note the CACHE FORCE stuff is required here + set(CMAKE_C_STANDARD_LIBRARIES CACHE STRING "" FORCE) + set(CMAKE_CXX_STANDARD_LIBRARIES CACHE STRING "" FORCE) else() set(_OSNAME unix) endif() @@ -57,6 +62,14 @@ if(MSVC) else() endif() +# TODO why do I need to do this? why doesn't target_link_libraries() work? +macro(_target_link_options_private _target) + foreach(_opt IN LISTS ${ARGN}) + set_property(TARGET ${_target} APPEND_STRING PROPERTY + LINK_FLAGS " ${_opt}") + endforeach() +endmacro() + add_subdirectory("common") add_subdirectory("${_OSNAME}") add_library(${_LIBUINAME} ${_LIBUI_SOURCES}) @@ -72,10 +85,10 @@ target_compile_options(${_LIBUINAME} target_link_libraries(${_LIBUINAME} ${_LIBUI_LINKMODE} ${_LIBUI_LIBS}) # on Windows the linker for static libraries is different; don't give it the flags -# TODO are these inherited? if(BUILD_SHARED_LIBS) - set_property(TARGET ${_LIBUINAME} APPEND PROPERTY - LINK_FLAGS ${_LIBUI_LDFLAGS}) + _target_link_options_private(${_LIBUINAME} + _COMMON_LDFLAGS + _LIBUI_LDFLAGS) endif() if(NOT BUILD_SHARED_LIBS) _handle_static() @@ -96,4 +109,7 @@ macro(_add_exec _name) WIN32 EXCLUDE_FROM_ALL ${ARGN}) target_link_libraries(${_name} libui) + _target_link_options_private(${_name} + _COMMON_LDFLAGS) endmacro() +add_subdirectory("test") diff --git a/migrate_build/CMakeLists.txt b/migrate_build/CMakeLists.txt index 79ebc0a8..130eaeea 100644 --- a/migrate_build/CMakeLists.txt +++ b/migrate_build/CMakeLists.txt @@ -176,8 +176,5 @@ else() endif() add_subdirectory("test") -set_target_properties(tester PROPERTIES - OUTPUT_NAME test - WIN32_EXECUTABLE FALSE) add_subdirectory("examples") diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 00000000..8d6ba03a --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,36 @@ +# 3 june 2016 + +if(WIN32) + set(_TEST_RESOURCES_RC resources.rc) +endif() + +_add_exec(tester + drawtests.c + main.c + menus.c + page1.c + page10.c + page11.c + page12.c + page13.c + page2.c + page3.c + page4.c + page5.c + page6.c + page7.c + page7a.c + page7b.c + page7c.c + page8.c + page9.c + spaced.c + ${_TEST_RESOURCES_RC} +) +target_include_directories(tester + PRIVATE test +) +set_target_properties(tester PROPERTIES + OUTPUT_NAME test + WIN32_EXECUTABLE FALSE +)