Created
October 21, 2014 12:47
-
-
Save shiva/521536ddea6425025606 to your computer and use it in GitHub Desktop.
cmake module for running nimrod compiler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include(CMakeParseArguments) | |
find_program(NIM_EXECUTABLE nimrod PATHS ENV PATH) | |
mark_as_advanced(NIM_EXECUTABLE) | |
# Determine the valac version | |
if(NIM_EXECUTABLE) | |
execute_process(COMMAND ${NIM_EXECUTABLE} "--version" | |
OUTPUT_VARIABLE NIM_VERSION | |
OUTPUT_STRIP_TRAILING_WHITESPACE) | |
STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" NIM_VERSION ${NIM_VERSION}) | |
endif(NIM_EXECUTABLE) | |
# Handle the QUIETLY and REQUIRED arguments, which may be given to the find call. | |
# set NIM_FOUND to TRUE if Nimrod has been found | |
include(FindPackageHandleStandardArgs) | |
find_package_handle_standard_args(Nim | |
REQUIRED_VARS NIM_EXECUTABLE | |
VERSION_VAR NIM_VERSION) | |
set(NIM_USE_FILE "${CMAKE_CURRENT_LIST_DIR}/UseNim.cmake") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include(CMakeParseArguments) | |
function(add_nim_executable ) | |
cmake_parse_arguments(ARGS "" "TARGET" "SOURCES" ${ARGN}) | |
# collect set of input source files | |
set(in_files "") | |
foreach(src ${ARGS_SOURCES} ${ARGS_UNPARSED_ARGUMENTS}) | |
list(APPEND in_files "${CMAKE_CURRENT_SOURCE_DIR}/${src}") | |
endforeach(src ${ARGS_SOURCES} ${ARGS_UNPARSED_ARGUMENTS}) | |
# set the target binary and nim cache directory | |
set(nim_target "${CMAKE_CURRENT_BINARY_DIR}/${ARGS_TARGET}") | |
set(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/nimcache") | |
# add target to trigger the nimrod compiler | |
add_custom_target( | |
nim ALL | |
COMMAND | |
${NIM_EXECUTABLE} "c" "--nimcache:" ${DIRECTORY} "--out:" ${nim_target} ${in_files} | |
DEPENDS | |
${in_files} | |
) | |
endfunction(add_nim_executable) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment