Skip to content
This repository was archived by the owner on Jul 24, 2021. It is now read-only.

Commit

Permalink
added sf2d package and imported targets for ctrulib
Browse files Browse the repository at this point in the history
  • Loading branch information
Lectem committed Sep 6, 2015
1 parent acf6dd4 commit 1a019c4
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 5 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,19 @@ This CMake variable is set to `-fomit-frame-pointer -ffast-math -fno-rtti -fno-e

## FindCTRULIB.cmake

You can use `find_package(CTRULIB)`. If found, `LIBCTRU_LIBRARIES` and `LIBCTRU_INCLUDE_DIRS` will be set.
You can use `find_package(CTRULIB)`.

If found, `LIBCTRU_LIBRARIES` and `LIBCTRU_INCLUDE_DIRS` will be set.
It also adds an imported target named `3ds::ctrulib`.
Linking it is the same as target_link_libraries(target ${LIBCTRU_LIBRARIES}) and target_include_directories(target ${LIBCTRU_INCLUDE_DIRS})

## FindSF2D.cmake

You can use `find_package(SF2D)`.

If found, `LIBSF2D_LIBRARIES` and `LIBSF2D_INCLUDE_DIRS` will be set.
It also adds an imported target named `3ds::sf2d`.
Linking it is the same as target_link_libraries(target ${LIBSF2D_LIBRARIES}) and target_include_directories(target ${LIBSF2D_INCLUDE_DIRS})

## Tools3DS.cmake

Expand Down
12 changes: 10 additions & 2 deletions cmake/FindCTRULIB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
# LIBCTRU_FOUND - System has ctrulib
# LIBCTRU_INCLUDE_DIRS - The ctrulib include directories
# LIBCTRU_LIBRARIES - The libraries needed to use ctrulib

#
# It also adds an imported target named `3ds::ctrulib`.
# Linking it is the same as target_link_libraries(target ${LIBCTRU_LIBRARIES}) and target_include_directories(target ${LIBCTRU_INCLUDE_DIRS})

# DevkitPro paths are broken on windows, so we have to fix those
macro(msys_to_cmake_path MsysPath ResultingPath)
Expand Down Expand Up @@ -37,4 +39,10 @@ mark_as_advanced(LIBCTRU_INCLUDE_DIR LIBCTRU_LIBRARY )
if(CTRULIB_FOUND)
set(CTRULIB ${LIBCTRU_INCLUDE_DIR}/..)
message(STATUS "setting CTRULIB to ${CTRULIB}")
endif()

add_library(3ds::ctrulib STATIC IMPORTED GLOBAL)
set_target_properties(3ds::ctrulib PROPERTIES
IMPORTED_LOCATION "${LIBCTRU_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${LIBCTRU_INCLUDE_DIR}"
)
endif()
45 changes: 45 additions & 0 deletions cmake/FindSF2D.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# - Try to find sf2d
# Once done this will define
# LIBSF2D_FOUND - System has sf2d
# LIBSF2D_INCLUDE_DIRS - The sf2d include directories
# LIBSF2D_LIBRARIES - The libraries needed to use sf2d
#
# It also adds an imported target named `3ds::sf2d`.
# Linking it is the same as target_link_libraries(target ${LIBSF2D_LIBRARIES}) and target_include_directories(target ${LIBSF2D_INCLUDE_DIRS})


# DevkitPro paths are broken on windows, so we have to fix those
macro(msys_to_cmake_path MsysPath ResultingPath)
string(REGEX REPLACE "^/([a-zA-Z])/" "\\1:/" ${ResultingPath} "${MsysPath}")
endmacro()

if(NOT DEVKITPRO)
msys_to_cmake_path("$ENV{DEVKITPRO}" DEVKITPRO)
endif()

find_path(LIBSF2D_INCLUDE_DIR sf2d.h
PATH_SUFFIXES include )

find_library(LIBSF2D_LIBRARY NAMES sf2d libsf2d.a
PATH_SUFFIXES lib)

set(LIBSF2D_LIBRARIES ${LIBSF2D_LIBRARY} )
set(LIBSF2D_INCLUDE_DIRS ${LIBSF2D_INCLUDE_DIR} )

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LIBSF2D_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(SF2D DEFAULT_MSG
LIBSF2D_LIBRARY LIBSF2D_INCLUDE_DIR)

mark_as_advanced(LIBSF2D_INCLUDE_DIR LIBSF2D_LIBRARY )
if(SF2D_FOUND)
set(SF2D ${LIBSF2D_INCLUDE_DIR}/..)
message(STATUS "setting SF2D to ${SF2D}")

add_library(3ds::sf2d STATIC IMPORTED)
set_target_properties(3ds::sf2d PROPERTIES
IMPORTED_LOCATION "${LIBSF2D_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${LIBSF2D_INCLUDE_DIR}"
)
endif()
3 changes: 1 addition & 2 deletions examples/simple_tri/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ file(GLOB_RECURSE SOURCE_FILES
)

add_executable(simple_tri ${SOURCE_FILES}) # Create the elf file
target_link_libraries(simple_tri ${LIBCTRU_LIBRARIES} m) # Link the shaders library, ctrulib and libm. This will also add the include directories needed for the embedded shaders.
target_include_directories(simple_tri PUBLIC ${LIBCTRU_INCLUDE_DIRS}) # Add the ctrulib include folder.
target_link_libraries(simple_tri 3ds::ctrulib m) # Link the shaders library, ctrulib and libm. This will also add the include directories for ctrulib.

target_embed_shader(simple_tri source/vshader.pica) # creates the shbin files and embed them into the app

Expand Down

0 comments on commit 1a019c4

Please sign in to comment.