Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some small fixes for cmake macos build #525

Merged
merged 6 commits into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Backends/RmlUi_Backend_GLFW_GL3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ bool Backend::Initialize(const char* name, int width, int height, bool allow_res
glfwWindowHint(GLFW_RESIZABLE, allow_resize ? GLFW_TRUE : GLFW_FALSE);
glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_TRUE);

glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);

GLFWwindow* window = glfwCreateWindow(width, height, name, nullptr, nullptr);
if (!window)
return false;
Expand Down
37 changes: 29 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ elseif( ENABLE_LOTTIE_PLUGIN )

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Dependencies/rlottie/build)
find_package(rlottie CONFIG)
find_path(rlottie_INCLUDE_DIR rlottie.h HINTS ${rlottie_DIR} $ENV{rlottie_DIR} PATH_SUFFIXES inc rlottie/inc )
find_path(rlottie_INCLUDE_DIR rlottie.h HINTS ${rlottie_DIR} $ENV{rlottie_DIR} PATH_SUFFIXES inc rlottie/inc ../inc)

if(rlottie_FOUND AND rlottie_INCLUDE_DIR)
message("-- Can Lottie plugin be added to RmlCore - yes - rlottie library found")
Expand Down Expand Up @@ -662,12 +662,33 @@ endif()
# Build samples ====================
#===================================

function(resource VAR SOURCE_PATH DESTINATION PATTERN)
file(GLOB_RECURSE _LIST CONFIGURE_DEPENDS ${SOURCE_PATH}/${PATTERN})
foreach (RESOURCE ${_LIST})
get_filename_component(_PARENT ${RESOURCE} DIRECTORY)
if (${_PARENT} STREQUAL ${SOURCE_PATH})
set(_DESTINATION ${DESTINATION})
else ()
file(RELATIVE_PATH _DESTINATION ${SOURCE_PATH} ${_PARENT})
set(_DESTINATION ${DESTINATION}/${_DESTINATION})
endif ()
set_property(SOURCE ${RESOURCE} PROPERTY MACOSX_PACKAGE_LOCATION ${_DESTINATION})
endforeach (RESOURCE)
set(${VAR} ${_LIST} PARENT_SCOPE)
endfunction()

# Build and link the samples
macro(bl_sample NAME)
macro(bl_sample NAME SAMPLE_SUB_DIR)
if (WIN32)
add_executable(${NAME} WIN32 ${${NAME}_SRC_FILES} ${${NAME}_HDR_FILES} )
elseif(APPLE)
add_executable(${NAME} MACOSX_BUNDLE ${${NAME}_SRC_FILES} ${${NAME}_HDR_FILES} )
resource(ASSETS ${SAMPLES_DIR}/assets Resources/assets *)
resource(DATA ${SAMPLES_DIR}/${SAMPLE_SUB_DIR}/data Resources/${SAMPLE_SUB_DIR}/data *)
resource(LUA ${SAMPLES_DIR}/${SAMPLE_SUB_DIR}/lua Resources/${SAMPLE_SUB_DIR}/lua *)

set(RESOURCE_FILES ${ASSETS} ${DATA} ${LUA})

add_executable(${NAME} MACOSX_BUNDLE ${${NAME}_SRC_FILES} ${${NAME}_HDR_FILES} ${RESOURCE_FILES})

# The first rpath is to the proper location where the framework/library SHOULD be, the second is to the location actually seen
# in the build environment
Expand Down Expand Up @@ -705,7 +726,7 @@ if(BUILD_SAMPLES OR BUILD_TESTING)
)
endif()

set(SAMPLES_DIR opt/RmlUi/Samples CACHE PATH "Path to samples directory.")
set(SAMPLES_DIR ${PROJECT_SOURCE_DIR}/Samples CACHE PATH "Path to samples directory.")
if(WIN32)
mark_as_advanced(SAMPLES_DIR)
endif()
Expand Down Expand Up @@ -863,7 +884,7 @@ if(BUILD_SAMPLES)

# Build and install the basic samples
foreach(sample ${samples})
bl_sample(${sample} ${sample_LIBRARIES})
bl_sample(${sample} basic/${sample} ${sample_LIBRARIES} )

# The samples always set this as their current working directory
install(DIRECTORY DESTINATION ${SAMPLES_DIR}/basic/${sample})
Expand All @@ -875,7 +896,7 @@ if(BUILD_SAMPLES)
# Build and install the tutorials
foreach(tutorial ${tutorials})
set(tutorial_fullname tutorial_${tutorial})
bl_sample(${tutorial_fullname} ${sample_LIBRARIES})
bl_sample(${tutorial_fullname} tutorial/${tutorial} ${sample_LIBRARIES})

# The tutorials always set this as their current working directory
install(DIRECTORY DESTINATION ${SAMPLES_DIR}/tutorial/${tutorial})
Expand All @@ -885,14 +906,14 @@ if(BUILD_SAMPLES)
endforeach()

# Build and install invaders sample
bl_sample(invaders ${sample_LIBRARIES})
bl_sample(invaders invaders ${sample_LIBRARIES})
install(DIRECTORY DESTINATION ${SAMPLES_DIR}/invaders)
install(TARGETS invaders
RUNTIME DESTINATION ${SAMPLES_DIR}/invaders
BUNDLE DESTINATION ${SAMPLES_DIR})

if(BUILD_LUA_BINDINGS)
bl_sample(luainvaders RmlLua ${sample_LIBRARIES} ${LUA_BINDINGS_LINK_LIBS})
bl_sample(luainvaders luainvaders RmlLua ${sample_LIBRARIES} ${LUA_BINDINGS_LINK_LIBS})
install(DIRECTORY DESTINATION ${SAMPLES_DIR}/luainvaders)
install(TARGETS luainvaders
RUNTIME DESTINATION ${SAMPLES_DIR}/luainvaders
Expand Down
2 changes: 1 addition & 1 deletion Samples/shell/src/PlatformExtensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Rml::String PlatformExtensions::FindSamplesRoot()

#elif defined RMLUI_PLATFORM_MACOSX

Rml::String path = "../../Samples/";
Rml::String path = "../Samples/";

// Find the location of the executable.
CFBundleRef bundle = CFBundleGetMainBundle();
Expand Down