aboutsummaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorJan200101 <sentrycraft123@gmail.com>2022-02-26 23:13:20 +0100
committerJan200101 <sentrycraft123@gmail.com>2022-02-26 23:13:20 +0100
commitdf179f7a92a24f83d70157768147e59fa5c63935 (patch)
tree732464722c4f68b852c29da27b4847bdc0c53ffe /cmake
parent1f1a17873db401ebcfab6c3e6be0d84731bb84c1 (diff)
downloadsameboy-thumbnailer-df179f7a92a24f83d70157768147e59fa5c63935.tar.gz
sameboy-thumbnailer-df179f7a92a24f83d70157768147e59fa5c63935.zip
add libpng support
Diffstat (limited to 'cmake')
-rw-r--r--cmake/FindSameBoy.cmake1
-rw-r--r--cmake/FindSameBoyBootRom.cmake6
-rw-r--r--cmake/Findlibpng.cmake68
-rw-r--r--cmake/Findlodepng.cmake23
4 files changed, 96 insertions, 2 deletions
diff --git a/cmake/FindSameBoy.cmake b/cmake/FindSameBoy.cmake
index 8fa0986..6f507e4 100644
--- a/cmake/FindSameBoy.cmake
+++ b/cmake/FindSameBoy.cmake
@@ -16,6 +16,7 @@ endif()
option(SAMEBOY_STATIC "" ON)
+mark_as_advanced(SAMEBOY_STATIC)
file(GLOB SAMEBOY_CORE_SOURCES ${SAMEBOY_PATH}/Core/*.c)
diff --git a/cmake/FindSameBoyBootRom.cmake b/cmake/FindSameBoyBootRom.cmake
index 81c9da0..5aadef3 100644
--- a/cmake/FindSameBoyBootRom.cmake
+++ b/cmake/FindSameBoyBootRom.cmake
@@ -6,12 +6,14 @@ set(SAMEBOY_BOOTROM_PATH ${SAMEBOY_PATH}/BootROMs)
set(SAMEBOY_BOOTROM_VERSION "cgb_boot" CACHE STRING "")
set(SAMEBOY_BOOTROM_SIZE "2304" CACHE STRING "")
+mark_as_advanced(SAMEBOY_BOOTROM_VERSION SAMEBOY_BOOTROM_SIZE)
add_executable(pb12 ${SAMEBOY_BOOTROM_PATH}/pb12.c)
find_program(RGBASM rgbasm REQUIRED)
-find_program(RBLINK rgblink REQUIRED)
+find_program(RGBLINK rgblink REQUIRED)
find_program(RGBGFX rgbgfx REQUIRED)
+mark_as_advanced(RGBASM RGBLINK RGBGFX)
# custom build step
add_custom_command(
@@ -30,7 +32,7 @@ add_custom_command(
COMMAND
${RGBASM} -o ${SAMEBOY_BOOTROM_VERSION}.tmp ${SAMEBOY_BOOTROM_PATH}/${SAMEBOY_BOOTROM_VERSION}.asm
COMMAND
- ${RBLINK} -o ${SAMEBOY_BOOTROM_VERSION}.tmp2 ${SAMEBOY_BOOTROM_VERSION}.tmp
+ ${RGBLINK} -o ${SAMEBOY_BOOTROM_VERSION}.tmp2 ${SAMEBOY_BOOTROM_VERSION}.tmp
COMMAND
dd if=${SAMEBOY_BOOTROM_VERSION}.tmp2 of=${SAMEBOY_BOOTROM_VERSION}.bin count=1 bs=${SAMEBOY_BOOTROM_SIZE}
DEPENDS SameBoyLogo.pb12
diff --git a/cmake/Findlibpng.cmake b/cmake/Findlibpng.cmake
new file mode 100644
index 0000000..62c4d87
--- /dev/null
+++ b/cmake/Findlibpng.cmake
@@ -0,0 +1,68 @@
+#
+# LIBPNG_INCLUDE_DIRS
+# LIBPNG_LIBRARIES
+# LIBPNG_CFLAGS
+# LIBPNG_FOUND
+
+
+find_package(PkgConfig QUIET)
+if (PKG_CONFIG_FOUND)
+ pkg_check_modules(_LIBPNG libpng)
+
+ if (BUILD_STATIC AND NOT _LIBPNG_FOUND)
+ message(FATAL_ERROR "Cannot find static build information")
+ endif()
+endif()
+set(LIBPNG_FOUND ${_LIBPNG_FOUND})
+
+if (_LIBPNG_FOUND) # we can rely on pkg-config
+
+ if (NOT BUILD_STATIC)
+ set(LIBPNG_LIBRARIES ${_LIBPNG_LIBRARIES})
+ set(LIBPNG_INCLUDE_DIRS ${_LIBPNG_INCLUDE_DIRS})
+ set(LIBPNG_CFLAGS ${_LIBPNG_CFLAGS_OTHER})
+ else()
+ set(LIBPNG_LIBRARIES ${_LIBPNG_STATIC_LIBRARIES})
+ set(LIBPNG_INCLUDE_DIRS ${_LIBPNG_STATIC_INCLUDE_DIRS})
+ set(LIBPNG_CFLAGS ${_LIBPNG_STATIC_CFLAGS_OTHER})
+ endif()
+else()
+ if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ set(_lib_suffix 64)
+ else()
+ set(_lib_suffix 32)
+ endif()
+
+ find_path(LIBPNG_INC
+ NAMES png.h
+ HINTS
+ ENV LIBPNGPath${_lib_suffix}
+ ENV LIBPNGPath
+ ${_LIBPNG_INCLUDE_DIRS}
+ PATHS
+ /usr/include/libpng16 /usr/local/include/libpng16
+ /usr/include/libpng /usr/local/include/libpng)
+
+ find_library(LIBPNG_LIB
+ NAMES ${_LIBPNG_LIBRARIES} libpng.so libpng16.so
+ HINTS
+ ENV LIBPNGPath${_lib_suffix}
+ ENV LIBPNGPath
+ ${_LIBPNG_LIBRARY_DIRS}
+ ${_LIBPNG_STATIC_LIBRARY_DIRS}
+ PATHS
+ /usr/lib${_lib_suffix} /usr/local/lib${_lib_suffix}
+ /usr/lib /usr/local/lib)
+
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(LIBPNG DEFAULT_MSG LIBPNG_LIB LIBPNG_INC)
+ mark_as_advanced(LIBPNG_INC LIBPNG_LIB)
+
+ if(LIBPNG_FOUND)
+ set(LIBPNG_INCLUDE_DIRS ${LIBPNG_INC})
+ set(LIBPNG_LIBRARIES ${LIBPNG_LIB})
+ if (BUILD_STATIC)
+ set(LIBPNG_LIBRARIES ${LIBPNG_LIBRARIES} ${_LIBPNG_STATIC_LIBRARIES})
+ endif()
+ endif()
+endif() \ No newline at end of file
diff --git a/cmake/Findlodepng.cmake b/cmake/Findlodepng.cmake
new file mode 100644
index 0000000..b8f7a01
--- /dev/null
+++ b/cmake/Findlodepng.cmake
@@ -0,0 +1,23 @@
+#
+# LODEPNG_INCLUDE_DIRS
+# LODEPNG_LIBRARIES
+# LODEPNG_CFLAGS
+
+
+if(LODEPNG_PATH)
+ return()
+endif()
+
+set(LODEPNG_PATH ${PROJECT_SOURCE_DIR}/deps/lodepng)
+
+list(APPEND
+ LODEPNG_SOURCES
+ ${LODEPNG_PATH}/lodepng.c
+ ${LODEPNG_PATH}/lodepng.h
+)
+
+add_library(lodepng STATIC ${LODEPNG_SOURCES})
+
+set(LODEPNG_INCLUDE_DIRS ${LODEPNG_PATH})
+set(LODEPNG_LIBRARIES lodepng)
+set(LODEPNG_CFLAGS "") \ No newline at end of file