Skip to content

Instantly share code, notes, and snippets.

@nicolas17
Forked from Madsy/gist:7384008
Last active December 27, 2015 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicolas17/7403278 to your computer and use it in GitHub Desktop.
Save nicolas17/7403278 to your computer and use it in GitHub Desktop.
SET( ${PROJECT_NAME}_SOURCES
main.cpp
)
#main.x depends on main.cpp (is generated based on main.cpp)
#main.o depends on main.cpp and main.x (main.x is included in main.cpp)
#So if main.cpp changes, first run the tool to create main.x,
#then run cc to create main.o from main.cpp and main.x
ADD_CUSTOM_COMMAND(
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT ${PROJECT_SOURCE_DIR}/main.x
COMMAND ./tool.sh main.cpp main.x
DEPENDS ${PROJECT_SOURCE_DIR}/main.cpp
)
SET_PROPERTY(SOURCE ${PROJECT_SOURCE_DIR}/main.cpp
APPEND PROPERTY OBJECT_DEPENDS ${PROJECT_SOURCE_DIR}/main.x)
ADD_EXECUTABLE(${PROJECT_NAME} ${${PROJECT_NAME}_SOURCES})
TARGET_LINK_LIBRARIES( ${PROJECT_NAME})
#include <cstdio>
#include "main.x"
int main()
{
printf("%s\n", txt);
return 0;
}
#!/bin/bash
echo "const char* txt = \"$1\"" >> $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment