
project(nstl)
cmake_minimum_required(VERSION 2.6)

file(
    GLOB_RECURSE
    editable_files
    "src/*.[c,h]" "include/*.[c,h]" "test/*.[c,h]"
)
set(cog "tools/cog/scripts/cog.py")
set(macroize "tools/macroize/macroize.py")
set(cog_flags "-Itools/")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")


add_custom_target(
    before-edit
    COMMAND python3 ${cog} ${cog_flags} -x -r ${editable_files}
    COMMAND python3 ${macroize} ${editable_files} -u
    WORKING_DIRECTORY "${nstl_SOURCE_DIR}"
)

add_custom_target(
    after-edit
    COMMAND python3 ${macroize} ${editable_files}
    COMMAND python3 ${cog} ${cog_flags} -r ${editable_files}
    WORKING_DIRECTORY "${nstl_SOURCE_DIR}"
)

include_directories("ext/chaos-pp" "ext/joy/include")
add_subdirectory(test)


project(nstl)
cmake_minimum_required(VERSION 2.6)

file(
    GLOB_RECURSE
    editable_files
    "src/*.[c,h]" "include/*.[c,h]" "test/*.[c,h]"
)
set(cog "tools/cog/scripts/cog.py")
set(macroize "tools/macroize/macroize.py")
set(cog_fix_pypath export "PYTHONPATH=${PYTHONPATH}:tools/cog")
set(cog_flags "-Itools/")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")


add_custom_target(
    before-edit
    COMMAND ${cog_fix_pypath} && python3 ${cog} ${cog_flags} -x -r ${editable_files}
    COMMAND python3 ${macroize} ${editable_files} -u
    WORKING_DIRECTORY "${nstl_SOURCE_DIR}"
)

add_custom_target(
    after-edit
    COMMAND python3 ${macroize} ${editable_files}
    COMMAND ${cog_fix_pypath} && python3 ${cog} ${cog_flags} -r ${editable_files}
    WORKING_DIRECTORY "${nstl_SOURCE_DIR}"
)

include_directories("ext/chaos-pp" "ext/joy/include")
add_subdirectory(test)

Fix a module import issue with Cog.
Fix a module import issue with Cog.

Cog would need to be installed in order to find its module in the PYTHONPATH,
so I added the tools/cog directory to the PYTHONPATH before invoking the
script in the Makefiles.
