Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

Commit

Permalink
Fix broken builds and missing install targets
Browse files Browse the repository at this point in the history
This commit rewrites the existing CMake files so that they
export targets and install required headers in a way that allows
the application and libraries to install and be idiomatically
integrated with other projects.

Included third-party code now builds object libraries that are
embedded in the final archives and public headers from those
third-party libraries are installed in subdirectories of the
embedding libraries.

This commit also fixes compiling the drawdance and dpgles2
targets and the emscripten cross-compilation, which were all
broken.

Across CMake files, verbose copyright headers are replaced with
SPDX identifiers plus an AUTHORS.txt for standard attribution.

Finally, this commit removes clang-format from CMake, since this
cannot work with all generators according to
<https://discourse.cmake.org/t/clang-format-integration/3358/4>
and should go into a git pre-commit hook instead or integrated in
the IDE.
  • Loading branch information
csnover committed Apr 4, 2023
1 parent fd13fa1 commit 34d6c18
Show file tree
Hide file tree
Showing 36 changed files with 1,068 additions and 1,000 deletions.
114 changes: 62 additions & 52 deletions 3rdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,7 @@
# Copyright (c) 2022 askmeaboutloom
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# SPDX-License-Identifier: MIT

if(BUILD_APPS)
add_library(lua STATIC lua/lapi.c lua/lapi.h lua/lauxlib.c lua/lauxlib.h
add_library(lua OBJECT lua/lapi.c lua/lapi.h lua/lauxlib.c lua/lauxlib.h
lua/lbaselib.c lua/lcode.c lua/lcode.h lua/lcorolib.c lua/lctype.c
lua/lctype.h lua/ldblib.c lua/ldebug.c lua/ldebug.h lua/ldo.c
lua/ldo.h lua/ldump.c lua/lfunc.c lua/lfunc.h lua/lgc.c lua/lgc.h
Expand All @@ -32,26 +14,32 @@ if(BUILD_APPS)
lua/ltm.h lua/lua.h lua/luaconf.h lua/lualib.h lua/lundump.c
lua/lundump.h lua/lutf8lib.c lua/lvm.c lua/lvm.h lua/lzio.c
lua/lzio.h )
set_dp_target_properties(lua NO_CLANG_TIDY NO_WARNINGS)
target_include_directories(lua INTERFACE "${CMAKE_CURRENT_LIST_DIR}/lua")
target_include_directories(lua SYSTEM PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/lua>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

add_clang_format_files(dpgles2/gles2_inc.h)
add_library(dpgles2 INTERFACE)
set_dp_target_properties(dpgles2 NO_ASAN NO_CLANG_TIDY NO_WARNINGS)
target_include_directories(dpgles2 INTERFACE "${CMAKE_CURRENT_LIST_DIR}/dpgles2")
target_include_directories(dpgles2 SYSTEM INTERFACE "dpgles2")

add_library(imgui STATIC imgui/imconfig.h imgui/imgui.cpp imgui/imgui_demo.cpp
add_library(imgui OBJECT imgui/imconfig.h imgui/imgui.cpp imgui/imgui_demo.cpp
imgui/imgui_draw.cpp imgui/imgui.h imgui/imgui_impl_opengl3.cpp
imgui/imgui_impl_opengl3.h imgui/imgui_impl_sdl.cpp
imgui/imgui_impl_sdl.h imgui/imgui_internal.h imgui/imgui_tables.cpp
imgui/imgui_widgets.cpp imgui/imstb_rectpack.h imgui/imstb_textedit.h
imgui/imstb_truetype.h)
set_dp_target_properties(imgui CXX NO_CLANG_TIDY NO_WARNINGS)
target_compile_definitions(imgui PRIVATE IMGUI_IMPL_OPENGL_ES2)
target_include_directories(imgui INTERFACE "${CMAKE_CURRENT_LIST_DIR}/imgui")
target_link_libraries(imgui PUBLIC dpgles2 SDL2::SDL2)
target_include_directories(imgui SYSTEM PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/imgui>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
target_link_libraries(imgui PRIVATE dpgles2 SDL2::SDL2)
# https://github.com/libsdl-org/SDL/issues/3657
if(APPLE AND SDL2_VERSION VERSION_LESS 2.0.13)
target_compile_definitions(imgui PRIVATE _DARWIN_C_SOURCE)
endif()

add_library(uriparser STATIC uriparser/UriCommon.c uriparser/UriCommon.h
add_library(uriparser OBJECT uriparser/UriCommon.c uriparser/UriCommon.h
uriparser/UriCompare.c uriparser/UriEscape.c uriparser/UriFile.c
uriparser/UriIp4.c uriparser/UriIp4Base.c uriparser/UriIp4Base.h
uriparser/UriMemory.c uriparser/UriMemory.h
Expand All @@ -65,27 +53,32 @@ if(BUILD_APPS)
uriparser/include/uriparser/UriDefsAnsi.h
uriparser/include/uriparser/UriDefsConfig.h
uriparser/include/uriparser/UriIp4.h)
set_dp_target_properties(uriparser NO_CLANG_TIDY NO_WARNINGS)
target_compile_definitions(uriparser PUBLIC URI_NO_UNICODE)
target_include_directories(
uriparser PRIVATE "${CMAKE_CURRENT_LIST_DIR}/uriparser")
target_include_directories(
uriparser PUBLIC "${CMAKE_CURRENT_LIST_DIR}/uriparser/include")
target_include_directories(uriparser SYSTEM
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/uriparser/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/uriparser>
)
endif()

add_library(parson STATIC parson/parson.c parson/parson.h)
set_dp_target_properties(parson NO_CLANG_TIDY NO_WARNINGS)
target_include_directories(parson INTERFACE "${CMAKE_CURRENT_LIST_DIR}/parson")
add_library(parson OBJECT parson/parson.c parson/parson.h)
target_include_directories(parson SYSTEM PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/parson>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

add_library(qgrayraster STATIC qgrayraster/qgrayraster.c
add_library(qgrayraster OBJECT qgrayraster/qgrayraster.c
qgrayraster/qgrayraster_inc.h
qgrayraster/qgrayraster_p.h
qgrayraster/qrasterdefs_p.h)
set_dp_target_properties(qgrayraster NO_CLANG_TIDY NO_WARNINGS)
target_include_directories(qgrayraster INTERFACE
"${CMAKE_CURRENT_LIST_DIR}/qgrayraster")
target_include_directories(qgrayraster SYSTEM PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/qgrayraster>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

add_library(mypaint STATIC libmypaint/brushsettings-gen.h
add_library(mypaint OBJECT libmypaint/brushsettings-gen.h
libmypaint/config.h libmypaint/fastapprox/cast.h
libmypaint/fastapprox/fasterf.h libmypaint/fastapprox/fastexp.h
libmypaint/fastapprox/fastgamma.h
Expand All @@ -104,15 +97,32 @@ add_library(mypaint STATIC libmypaint/brushsettings-gen.h
libmypaint/mypaint-rectangle.h libmypaint/mypaint-surface.c
libmypaint/mypaint-surface.h libmypaint/rng-double.c
libmypaint/rng-double.h )
set_dp_target_properties(mypaint NO_CLANG_TIDY NO_WARNINGS)
target_include_directories(mypaint INTERFACE
"${CMAKE_CURRENT_LIST_DIR}/libmypaint")
target_include_directories(mypaint SYSTEM PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/libmypaint>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

add_library(uthash INTERFACE)
set_dp_target_properties(uthash NO_CLANG_TIDY NO_WARNINGS)
target_include_directories(uthash INTERFACE "${CMAKE_CURRENT_LIST_DIR}/uthash")
target_include_directories(uthash INTERFACE "uthash")

add_library(jo_gifx STATIC jo_gifx/jo_gifx.h jo_gifx/jo_gifx.c)
set_dp_target_properties(jo_gifx NO_WARNINGS)
target_include_directories(
jo_gifx INTERFACE "${CMAKE_CURRENT_LIST_DIR}/jo_gifx")
add_library(jo_gifx OBJECT jo_gifx/jo_gifx.h jo_gifx/jo_gifx.c)
target_include_directories(jo_gifx SYSTEM PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/jo_gifx>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

# The project root adds compiler warnings and tidy to all targets, but
# third-party code does not follow the same code hygiene rules, so turn those
# off for everything in this directory
get_directory_property(third_party_targets BUILDSYSTEM_TARGETS)
set_property(TARGET ${third_party_targets} APPEND PROPERTY
COMPILE_OPTIONS "${IGNORE_WARNINGS_COMPILE_OPTIONS}"
)
# It is not possible to use the same approach that was used to disable
# warnings because CMake apparently discards empty list items when a list is
# passed to set_target_properties, so instead we must loop to unset each
# property
foreach(ignore_tidy IN LISTS IGNORE_TIDY_PROPERTY_NAMES)
set_property(TARGET ${third_party_targets} PROPERTY ${ignore_tidy})
endforeach()
unset(third_party_targets)
2 changes: 1 addition & 1 deletion 3rdparty/dpgles2/gl2.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ extern "C" {

#ifndef GL_ES_VERSION_2_0
#define GL_ES_VERSION_2_0 1
#include "../KHR/khrplatform.h"
#include "khrplatform.h"
typedef khronos_int8_t GLbyte;
typedef khronos_float_t GLclampf;
typedef khronos_int32_t GLfixed;
Expand Down
2 changes: 1 addition & 1 deletion 3rdparty/dpgles2/gl2platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* https://github.com/KhronosGroup/OpenGL-Registry
*/

#include "../KHR/khrplatform.h"
#include "khrplatform.h"

#ifndef GL_APICALL
#define GL_APICALL KHRONOS_APICALL
Expand Down
Loading

0 comments on commit 34d6c18

Please sign in to comment.