metaforce/hecl/shaderc/CMakeLists.txt

39 lines
1.2 KiB
CMake

add_library(shaderc_lib shaderc.cpp shaderc.hpp)
target_link_libraries(shaderc_lib PUBLIC hecl-compilers athena-core logvisor)
add_executable(shaderc main.cpp)
target_link_libraries(shaderc shaderc_lib)
if (NOT WIN32)
target_link_libraries(shaderc pthread)
if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
target_link_libraries(shaderc execinfo)
else()
target_link_libraries(shaderc dl)
endif()
endif()
if(COMMAND add_sanitizers)
add_sanitizers(shaderc_lib)
add_sanitizers(shaderc)
endif()
function(shaderc out)
if(IS_ABSOLUTE ${out})
set(theOut ${out})
else()
set(theOut ${CMAKE_CURRENT_BINARY_DIR}/${out})
endif()
unset(theInsList)
foreach(in ${ARGN})
if(IS_ABSOLUTE ${in})
list(APPEND theInsList ${in})
else()
list(APPEND theInsList ${CMAKE_CURRENT_SOURCE_DIR}/${in})
endif()
endforeach()
get_filename_component(outDir ${theOut} DIRECTORY)
file(MAKE_DIRECTORY ${outDir})
file(RELATIVE_PATH outRel ${CMAKE_BINARY_DIR} ${theOut})
add_custom_command(OUTPUT ${theOut}.cpp ${theOut}.hpp
COMMAND $<TARGET_FILE:shaderc> ARGS -o ${theOut} ${theInsList}
DEPENDS ${theInsList} shaderc COMMENT "Compiling shader ${outRel}.shader")
endfunction()