set(_LIBUI_HEADERS . common ${_OSDIR}) file(GLOB _LIBUI_SOURCES common/*.c ${_OSDIR}/*.${_OSSRCEXT}) macro(_begin_shared _cflags _cxxflags _ldflags) set(CMAKE_C_FLAGS "${_cflags}") set(CMAKE_CXX_FLAGS "${_cxxflags}") set(CMAKE_SHARED_LINKER_FLAGS "${_ldflags}") endmacro() macro(libui _name _mode) add_library(${_name} ${_mode} ${SOURCES}) set_target_properties(${_name} PROPERTIES OUTPUT_NAME ui) if("${_mode}" STREQUAL "SHARED") # only put version number on shared build set_target_properties(${_name} PROPERTIES SOVERSION ${_VERSION}) else() # don't build libui-static by default set_target_properties(${_name} PROPERTIES EXCLUDE_FROM_ALL 1) endif() set_target_properties(${_name} PROPERTIES COMPILE_FLAGS "${_LIBUI_CFLAGS}") set_target_properties(${_name} PROPERTIES LINK_FLAGS "${_PICFLAG} ${_LIBUI_LDFLAGS}") endmacro() libui(libui SHARED ${_SETVERSION} FALSE) if(${_NOSHARED}) nosharedmingw(libui-static) else() libui(libui-static STATIC FALSE TRUE) endif() include_directories(test) file(GLOB TESTSOURCES test/*.c) macro(executable_base _name _outname _libui _static) add_executable(${_name} ${XSRC}) set_target_properties(${_name} PROPERTIES OUTPUT_NAME ${_outname} EXCLUDE_FROM_ALL 1) target_link_libraries(${_name} ${_libui}) # be sure to include libui libraries in the output if(${_static}) set_target_properties(${_name} PROPERTIES LINK_FLAGS "${_LIBUI_LDFLAGS}") else() set_target_properties(${_name} PROPERTIES LINK_FLAGS "${_PICFLAG}") endif() endmacro() macro(executable _name _outname _dir) include_directories(${_dir}) file(GLOB XSRC ${_dir}/*.c ${_dir}/*.cpp) executable_base(${_name} ${_outname} libui FALSE) if(${_NOSHARED}) nosharedmingw(${_name}-static) else() executable_base(${_name}-static ${_outname} libui-static TRUE) endif() set(XSRC) endmacro() executable(tester test test) executable(controlgallery controlgallery examples/controlgallery) executable(histogram histogram examples/histogram) executable(cpp-multithread cpp-multithread examples/cpp-multithread) add_custom_target(examples DEPENDS controlgallery histogram cpp-multithread) add_custom_target(examples-static DEPENDS controlgallery-static histogram-static cpp-multithread-static)