2014-09-27 04:44:47 +04:00
|
|
|
#
|
2014-11-22 03:42:44 +03:00
|
|
|
# "$Id$"
|
2014-09-27 04:44:47 +04:00
|
|
|
#
|
2018-02-09 23:51:15 +03:00
|
|
|
# Macros used by the CMake build system for the Fast Light Tool Kit (FLTK).
|
2014-09-27 04:44:47 +04:00
|
|
|
# Written by Michael Surette
|
|
|
|
#
|
2018-02-09 23:51:15 +03:00
|
|
|
# Copyright 1998-2018 by Bill Spitzak and others.
|
2014-09-27 04:44:47 +04:00
|
|
|
#
|
|
|
|
# This library is free software. Distribution and use rights are outlined in
|
|
|
|
# the file "COPYING" which should have been included with this file. If this
|
|
|
|
# file is missing or damaged, see the license at:
|
|
|
|
#
|
|
|
|
# http://www.fltk.org/COPYING.php
|
|
|
|
#
|
|
|
|
# Please report all bugs and problems on the following page:
|
|
|
|
#
|
|
|
|
# http://www.fltk.org/str.php
|
|
|
|
#
|
|
|
|
|
2018-02-09 23:51:15 +03:00
|
|
|
#######################################################################
|
|
|
|
# macros used for debugging purposes
|
|
|
|
#######################################################################
|
|
|
|
|
|
|
|
# This macro displays the name and value of a CMake variable.
|
|
|
|
# The variable name is expanded with spaces to be (at least)
|
|
|
|
# <min_len> (currently 24) characters wide for better readability.
|
|
|
|
# VARNAME must be a string literal, e.g. WIN32 or "WIN32".
|
|
|
|
#
|
|
|
|
# Syntax:
|
|
|
|
# fl_debug_var(VARNAME)
|
|
|
|
#
|
|
|
|
# Example:
|
|
|
|
# fl_debug_var(WIN32)
|
|
|
|
# fl_debug_var("UNIX")
|
|
|
|
#
|
|
|
|
|
|
|
|
macro (fl_debug_var name)
|
|
|
|
set (min_len 24)
|
|
|
|
set (var "${name}")
|
|
|
|
string(LENGTH "${var}" len)
|
|
|
|
while (len LESS min_len)
|
|
|
|
string(APPEND var " ")
|
|
|
|
string(LENGTH "${var}" len)
|
|
|
|
endwhile (len LESS min_len)
|
|
|
|
message (STATUS "${var} = '${${name}}'")
|
|
|
|
endmacro (fl_debug_var)
|
|
|
|
|
2014-09-27 04:44:47 +04:00
|
|
|
#######################################################################
|
|
|
|
# macros used by the build system
|
|
|
|
#######################################################################
|
|
|
|
macro(FL_ADD_LIBRARY LIBNAME LIBTYPE LIBFILES)
|
|
|
|
|
2016-03-26 17:33:20 +03:00
|
|
|
if (${LIBTYPE} STREQUAL "SHARED")
|
|
|
|
set (LIBRARY_NAME ${LIBNAME}_SHARED)
|
|
|
|
else ()
|
|
|
|
set (LIBRARY_NAME ${LIBNAME})
|
|
|
|
endif (${LIBTYPE} STREQUAL "SHARED")
|
|
|
|
|
|
|
|
if (MSVC)
|
2016-08-09 17:11:42 +03:00
|
|
|
set (LIBRARY_NAME_DEBUG "${LIBRARY_NAME}d")
|
2016-03-26 17:33:20 +03:00
|
|
|
else ()
|
2016-08-09 17:11:42 +03:00
|
|
|
set (LIBRARY_NAME_DEBUG "${LIBRARY_NAME}")
|
2016-03-26 17:33:20 +03:00
|
|
|
endif (MSVC)
|
2014-09-27 04:44:47 +04:00
|
|
|
|
|
|
|
add_library(${LIBRARY_NAME} ${LIBTYPE} ${LIBFILES})
|
|
|
|
|
|
|
|
set_target_properties(${LIBRARY_NAME}
|
|
|
|
PROPERTIES
|
2016-08-09 17:11:42 +03:00
|
|
|
OUTPUT_NAME ${LIBRARY_NAME}
|
|
|
|
DEBUG_OUTPUT_NAME ${LIBRARY_NAME_DEBUG}
|
2014-09-27 04:44:47 +04:00
|
|
|
CLEAN_DIRECT_OUTPUT TRUE
|
|
|
|
COMPILE_DEFINITIONS "FL_LIBRARY"
|
2016-03-26 17:33:20 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
if (${LIBTYPE} STREQUAL "SHARED")
|
|
|
|
set_target_properties(${LIBRARY_NAME}
|
|
|
|
PROPERTIES
|
|
|
|
VERSION ${FLTK_VERSION_FULL}
|
|
|
|
SOVERSION ${FLTK_VERSION_MAJOR}.${FLTK_VERSION_MINOR}
|
|
|
|
PREFIX "lib" # for MSVC static/shared coexistence
|
|
|
|
)
|
|
|
|
endif (${LIBTYPE} STREQUAL "SHARED")
|
|
|
|
|
|
|
|
if (MSVC)
|
|
|
|
if (OPTION_LARGE_FILE)
|
2016-08-09 17:11:42 +03:00
|
|
|
set_target_properties(${LIBRARYNAME}
|
2016-03-26 17:33:20 +03:00
|
|
|
PROPERTIES
|
|
|
|
LINK_FLAGS /LARGEADDRESSAWARE
|
|
|
|
)
|
|
|
|
endif (OPTION_LARGE_FILE)
|
2014-09-27 04:44:47 +04:00
|
|
|
|
2016-03-26 17:33:20 +03:00
|
|
|
if (${LIBTYPE} STREQUAL "SHARED")
|
|
|
|
set_target_properties(${LIBRARY_NAME}
|
|
|
|
PROPERTIES
|
|
|
|
COMPILE_DEFINITIONS "FL_DLL"
|
|
|
|
)
|
|
|
|
endif (${LIBTYPE} STREQUAL "SHARED")
|
|
|
|
endif (MSVC)
|
2014-09-27 04:44:47 +04:00
|
|
|
|
|
|
|
install(TARGETS ${LIBRARY_NAME}
|
|
|
|
EXPORT FLTK-Targets
|
2015-02-16 17:30:27 +03:00
|
|
|
RUNTIME DESTINATION ${FLTK_BINDIR}
|
|
|
|
LIBRARY DESTINATION ${FLTK_LIBDIR}
|
|
|
|
ARCHIVE DESTINATION ${FLTK_LIBDIR}
|
2016-03-26 17:33:20 +03:00
|
|
|
)
|
2014-09-27 04:44:47 +04:00
|
|
|
|
|
|
|
list(APPEND FLTK_LIBRARIES "${LIBRARY_NAME}")
|
2016-03-26 17:33:20 +03:00
|
|
|
set (FLTK_LIBRARIES ${FLTK_LIBRARIES} PARENT_SCOPE)
|
2014-09-27 04:44:47 +04:00
|
|
|
|
|
|
|
endmacro(FL_ADD_LIBRARY LIBNAME LIBTYPE LIBFILES)
|
|
|
|
|
2016-01-29 16:40:08 +03:00
|
|
|
#######################################################################
|
|
|
|
# USAGE: FLTK_RUN_FLUID TARGET_NAME "FLUID_SOURCE [.. FLUID_SOURCE]"
|
|
|
|
function(FLTK_RUN_FLUID TARGET SOURCES)
|
2016-03-26 17:33:20 +03:00
|
|
|
set (CXX_FILES)
|
2016-01-29 16:40:08 +03:00
|
|
|
foreach(src ${SOURCES})
|
2016-03-26 17:33:20 +03:00
|
|
|
if ("${src}" MATCHES "\\.fl$")
|
2016-01-29 16:40:08 +03:00
|
|
|
string(REGEX REPLACE "(.*).fl" \\1 basename ${src})
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT "${basename}.cxx" "${basename}.h"
|
|
|
|
COMMAND fluid -c ${CMAKE_CURRENT_SOURCE_DIR}/${src}
|
2016-03-26 17:33:20 +03:00
|
|
|
DEPENDS ${src}
|
|
|
|
MAIN_DEPENDENCY ${src}
|
2016-01-29 16:40:08 +03:00
|
|
|
)
|
|
|
|
list(APPEND CXX_FILES "${basename}.cxx")
|
2016-03-26 17:33:20 +03:00
|
|
|
endif ("${src}" MATCHES "\\.fl$")
|
|
|
|
set (${TARGET} ${CXX_FILES} PARENT_SCOPE)
|
|
|
|
endforeach(src)
|
2016-01-29 16:40:08 +03:00
|
|
|
endfunction(FLTK_RUN_FLUID TARGET SOURCES)
|
|
|
|
|
2014-09-27 04:44:47 +04:00
|
|
|
#######################################################################
|
|
|
|
macro(CREATE_EXAMPLE NAME SOURCES LIBRARIES)
|
|
|
|
|
2016-03-26 17:33:20 +03:00
|
|
|
set (srcs) # source files
|
|
|
|
set (flsrcs) # fluid source files
|
2014-10-09 20:11:36 +04:00
|
|
|
|
2016-03-26 17:33:20 +03:00
|
|
|
set (tname ${NAME}) # target name
|
|
|
|
set (oname ${NAME}) # output (executable) name
|
2014-10-09 20:11:36 +04:00
|
|
|
|
2014-09-27 04:44:47 +04:00
|
|
|
foreach(src ${SOURCES})
|
2016-03-26 17:33:20 +03:00
|
|
|
if ("${src}" MATCHES "\\.fl$")
|
2014-09-27 04:44:47 +04:00
|
|
|
list(APPEND flsrcs ${src})
|
2016-03-26 17:33:20 +03:00
|
|
|
else ()
|
2014-09-27 04:44:47 +04:00
|
|
|
list(APPEND srcs ${src})
|
2016-03-26 17:33:20 +03:00
|
|
|
endif ("${src}" MATCHES "\\.fl$")
|
2014-09-27 04:44:47 +04:00
|
|
|
endforeach(src)
|
|
|
|
|
2016-03-26 17:33:20 +03:00
|
|
|
set (FLUID_SOURCES)
|
|
|
|
if (flsrcs)
|
2016-01-29 16:40:08 +03:00
|
|
|
FLTK_RUN_FLUID(FLUID_SOURCES "${flsrcs}")
|
2016-03-26 17:33:20 +03:00
|
|
|
endif (flsrcs)
|
|
|
|
|
|
|
|
if (APPLE AND (NOT OPTION_APPLE_X11) AND (NOT OPTION_APPLE_SDL))
|
|
|
|
unset (RESOURCE_PATH)
|
|
|
|
if (${tname} STREQUAL "blocks" OR ${tname} STREQUAL "checkers" OR ${tname} STREQUAL "sudoku")
|
|
|
|
set (ICON_NAME ${tname}.icns)
|
|
|
|
set (RESOURCE_PATH "${PROJECT_SOURCE_DIR}/test/${tname}.app/Contents/Resources/${ICON_NAME}")
|
|
|
|
elseif (${tname} STREQUAL "demo")
|
|
|
|
set (RESOURCE_PATH "${PROJECT_SOURCE_DIR}/test/demo.menu")
|
|
|
|
endif (${tname} STREQUAL "blocks" OR ${tname} STREQUAL "checkers" OR ${tname} STREQUAL "sudoku")
|
|
|
|
|
|
|
|
if (DEFINED RESOURCE_PATH)
|
2016-01-29 16:40:08 +03:00
|
|
|
add_executable(${tname} MACOSX_BUNDLE ${srcs} ${FLUID_SOURCES} ${RESOURCE_PATH})
|
2016-03-26 17:33:20 +03:00
|
|
|
if (${tname} STREQUAL "demo")
|
2015-04-08 15:16:52 +03:00
|
|
|
target_compile_definitions(demo PUBLIC USING_XCODE)
|
2016-03-26 17:33:20 +03:00
|
|
|
endif (${tname} STREQUAL "demo")
|
|
|
|
else ()
|
2016-01-29 16:40:08 +03:00
|
|
|
add_executable(${tname} MACOSX_BUNDLE ${srcs} ${FLUID_SOURCES})
|
2016-03-26 17:33:20 +03:00
|
|
|
endif (DEFINED RESOURCE_PATH)
|
|
|
|
else ()
|
2016-01-29 16:40:08 +03:00
|
|
|
add_executable(${tname} WIN32 ${srcs} ${FLUID_SOURCES})
|
2016-03-26 17:33:20 +03:00
|
|
|
endif (APPLE AND (NOT OPTION_APPLE_X11) AND (NOT OPTION_APPLE_SDL))
|
2015-04-07 18:31:12 +03:00
|
|
|
|
2016-03-26 17:33:20 +03:00
|
|
|
set_target_properties(${tname}
|
2016-01-29 16:40:08 +03:00
|
|
|
PROPERTIES OUTPUT_NAME ${oname}
|
|
|
|
)
|
2016-03-26 17:33:20 +03:00
|
|
|
if (APPLE AND DEFINED RESOURCE_PATH)
|
|
|
|
if (NOT ${tname} STREQUAL "demo")
|
2015-04-08 15:16:52 +03:00
|
|
|
set_target_properties(${tname} PROPERTIES MACOSX_BUNDLE_ICON_FILE ${ICON_NAME})
|
2016-03-26 17:33:20 +03:00
|
|
|
endif (NOT ${tname} STREQUAL "demo")
|
2015-04-08 15:16:52 +03:00
|
|
|
set_target_properties(${tname} PROPERTIES RESOURCE ${RESOURCE_PATH})
|
2016-03-26 17:33:20 +03:00
|
|
|
endif (APPLE AND DEFINED RESOURCE_PATH)
|
|
|
|
if (APPLE AND (NOT OPTION_APPLE_X11) AND (NOT OPTION_APPLE_SDL) AND ${tname} STREQUAL "editor")
|
2016-02-02 11:58:33 +03:00
|
|
|
set_target_properties("editor" PROPERTIES MACOSX_BUNDLE_INFO_PLIST "${PROJECT_SOURCE_DIR}/test/editor-Info.plist" )
|
2016-03-02 03:54:37 +03:00
|
|
|
endif(APPLE AND (NOT OPTION_APPLE_X11) AND (NOT OPTION_APPLE_SDL) AND ${tname} STREQUAL "editor")
|
2016-03-26 17:33:20 +03:00
|
|
|
|
2014-10-09 20:11:36 +04:00
|
|
|
target_link_libraries(${tname} ${LIBRARIES})
|
2014-09-27 04:44:47 +04:00
|
|
|
|
|
|
|
endmacro(CREATE_EXAMPLE NAME SOURCES LIBRARIES)
|
|
|
|
|
|
|
|
#######################################################################
|