More cmake work.

This commit is contained in:
Pietro Gagliardi 2016-05-30 13:28:27 -04:00
parent 0fc4ff588f
commit ee8b4f71c0
1 changed files with 42 additions and 18 deletions

View File

@ -2,16 +2,11 @@
cmake_minimum_required(VERSION 2.8.12)
project(libui)
option(examples "Build the example projects" OFF)
option(test "Build the test project" OFF)
set(_OSDIR unix)
set(_OSSRCEXT c)
set(_OUTNAME libui.so.0)
if(APPLE)
set(_OSDIR darwin)
set(_OSSRCEXT m)
set(_OUTNAME libui.A.dylib)
set(_SETVERSION TRUE)
set(_VERSION "A")
# always use our rpath
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
@ -21,22 +16,51 @@ if(APPLE)
elseif(WINDOWS)
set(_OSDIR windows)
set(_OSSRCEXT cpp)
set(_OUTNAME libui.dll)
set(_SETVERSION FALSE)
else(APPLE)
set(_OSDIR unix)
set(_OSSRCEXT c)
set(_SETVERSION TRUE)
set(_VERSION "0")
# always use our rpath
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
endif(APPLE)
include_directories(. common ${_OSDIR} test)
file(GLOB SOURCES
common/*.c
${_OSDIR}/*.${_OSSRCEXT})
add_library(libui SHARED ${SOURCES})
set_target_properties(libui PROPERTIES OUTPUT_NAME ${_OUTNAME})
target_link_libraries(libui "-framework Foundation -framework AppKit")
macro(libui _name _mode _setver _exclude)
add_library(${_name} ${_mode} ${SOURCES})
set_target_properties(${_name} PROPERTIES
OUTPUT_NAME ui)
if(${_setver})
set_target_properties(${_name} PROPERTIES
SOVERSION ${_VERSION})
endif(${_setver})
# omit libui-shared from default builds
if(${_exclude})
set_target_properties(${_name} PROPERTIES
EXCLUDE_FROM_ALL 1)
endif(${_exclude})
target_link_libraries(${_name} "-framework Foundation -framework AppKit")
endmacro(libui)
if(test)
file(GLOB TESTSOURCES test/*.c)
add_executable(tester ${TESTSOURCES})
set_target_properties(tester PROPERTIES OUTPUT_NAME test)
target_link_libraries(tester libui)
endif(test)
libui(libui SHARED ${_SETVERSION} FALSE)
libui(libui-static STATIC FALSE TRUE)
include_directories(test)
file(GLOB TESTSOURCES test/*.c)
macro(test _name _libui)
add_executable(${_name} ${TESTSOURCES})
set_target_properties(${_name} PROPERTIES
OUTPUT_NAME test
EXCLUDE_FROM_ALL 1)
target_link_libraries(${_name} ${_libui})
endmacro(test)
test(tester libui)
test(tester-static libui-static)