More cmake work. Better, but not all there.

This commit is contained in:
Pietro Gagliardi 2016-06-02 12:52:32 -04:00
parent 2d1b6093f0
commit da8649312e
1 changed files with 16 additions and 4 deletions

View File

@ -78,6 +78,10 @@ elseif(WIN32)
set(_PLATFORM_LIBS set(_PLATFORM_LIBS
user32 kernel32 usp10 gdi32 comctl32 uxtheme msimg32 comdlg32 d2d1 dwrite ole32 oleaut32 oleacc uuid user32 kernel32 usp10 gdi32 comctl32 uxtheme msimg32 comdlg32 d2d1 dwrite ole32 oleaut32 oleacc uuid
) )
# and don't include the default libraries
# note the CACHE FORCE stuff is required here
set(CMAKE_C_STANDARD_LIBRARIES CACHE STRING "" FORCE)
set(CMAKE_CXX_STANDARD_LIBRARIES CACHE STRING "" FORCE)
set(_RESOURCES_RC resources.rc) set(_RESOURCES_RC resources.rc)
else() else()
@ -103,6 +107,8 @@ if(MSVC)
# LONGTERM still needed? # LONGTERM still needed?
append(CMAKE_CXX_FLAGS " /EHsc") append(CMAKE_CXX_FLAGS " /EHsc")
append(_LIBUI_CFLAGS " ${_PLATFORM_CFLAGS}")
# note the /MANIFEST:NO (which must be / and uppercase); thanks FraGag (https://github.com/andlabs/libui/issues/93#issuecomment-223183436) # note the /MANIFEST:NO (which must be / and uppercase); thanks FraGag (https://github.com/andlabs/libui/issues/93#issuecomment-223183436)
# also don't apply to CMAKE_STATIC_LINKER_FLAGS; those are passed to a different tool that doesn't support them # also don't apply to CMAKE_STATIC_LINKER_FLAGS; those are passed to a different tool that doesn't support them
append2(CMAKE_SHARED_LINKER_FLAGS CMAKE_EXE_LINKER_FLAGS append2(CMAKE_SHARED_LINKER_FLAGS CMAKE_EXE_LINKER_FLAGS
@ -126,11 +132,9 @@ else()
endif() endif()
if(WIN32) if(WIN32)
append(_LIBUI_CFLAGS append(_LIBUI_CFLAGS " ${_PLATFORM_CFLAGS}")
" -D _UI_EXTERN=\"__declspec(dllexport) extern\" ${_PLATFORM_CFLAGS}")
else() else()
append(_LIBUI_CFLAGS append(_LIBUI_CFLAGS " -fvisibility=hidden ${_PLATFORM_CFLAGS}")
" -D_UI_EXTERN='__attribute__((visibility(\"default\"))) extern' -fvisibility=hidden ${_PLATFORM_CFLAGS}")
endif() endif()
append(CMAKE_SHARED_LINKER_FLAGS " -fvisibility=hidden") append(CMAKE_SHARED_LINKER_FLAGS " -fvisibility=hidden")
@ -164,6 +168,14 @@ if(NOT WIN32)
set_target_properties(libui PROPERTIES set_target_properties(libui PROPERTIES
OUTPUT_NAME ui) OUTPUT_NAME ui)
endif() endif()
# let cmake handle quoting and escaping for us
if(WIN32)
set_target_properties(libui PROPERTIES
COMPILE_DEFINITIONS "_UI_EXTERN=__declspec(dllexport) extern")
else()
set_target_properties(libui PROPERTIES
COMPILE_DEFINITIONS "_UI_EXTERN=__attribute__((visibility(\"default\"))) extern")
endif()
macro(_add_exec _name) macro(_add_exec _name)
add_executable(${_name} add_executable(${_name}