-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Project Structure
- Loading branch information
0 parents
commit 5c00435
Showing
18 changed files
with
590 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
Build/ | ||
Builds/ | ||
|
||
# Prerequisites | ||
*.d | ||
|
||
# Compiled Object files | ||
*.slo | ||
*.lo | ||
*.o | ||
*.obj | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Compiled Dynamic libraries | ||
*.so | ||
*.dylib | ||
*.dll | ||
|
||
# Fortran module files | ||
*.mod | ||
*.smod | ||
|
||
# Compiled Static libraries | ||
*.lai | ||
*.la | ||
*.a | ||
*.lib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app | ||
*.ps1 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Detect CLANG | ||
if (NOT LLVM_INCLUDE_DIR OR NOT LLVM_LIB_DIR) | ||
message(FATAL_ERROR "No LLVM and Clang support requires LLVM") | ||
else (NOT LLVM_INCLUDE_DIR OR NOT LLVM_LIB_DIR) | ||
|
||
MACRO(FIND_AND_ADD_CLANG_LIB _libname_) | ||
find_library(CLANG_${_libname_}_LIB ${_libname_} ${LLVM_LIB_DIR} ${CLANG_LIB_DIR}) | ||
if (CLANG_${_libname_}_LIB) | ||
set(CLANG_LIBS ${CLANG_LIBS} ${CLANG_${_libname_}_LIB}) | ||
endif(CLANG_${_libname_}_LIB) | ||
ENDMACRO(FIND_AND_ADD_CLANG_LIB) | ||
|
||
set(CLANG_INCLUDE_DIRS ${CLANG_INCLUDE_DIRS} ${LLVM_INCLUDE_DIR}) | ||
set(CLANG_INCLUDE_DIRS ${CLANG_INCLUDE_DIRS} ${CLANG_INCLUDE_DIR}) | ||
|
||
FIND_AND_ADD_CLANG_LIB(clangFrontend) | ||
FIND_AND_ADD_CLANG_LIB(clangDriver) | ||
FIND_AND_ADD_CLANG_LIB(clangCodeGen) | ||
FIND_AND_ADD_CLANG_LIB(clangSema) | ||
FIND_AND_ADD_CLANG_LIB(clangChecker) | ||
FIND_AND_ADD_CLANG_LIB(clangAnalysis) | ||
FIND_AND_ADD_CLANG_LIB(clangRewrite) | ||
FIND_AND_ADD_CLANG_LIB(clangAST) | ||
FIND_AND_ADD_CLANG_LIB(clangParse) | ||
FIND_AND_ADD_CLANG_LIB(clangLex) | ||
FIND_AND_ADD_CLANG_LIB(clangBasic) | ||
FIND_AND_ADD_CLANG_LIB(clangARCMigrate) | ||
FIND_AND_ADD_CLANG_LIB(clangEdit) | ||
FIND_AND_ADD_CLANG_LIB(clangFrontendTool) | ||
FIND_AND_ADD_CLANG_LIB(clangRewrite) | ||
FIND_AND_ADD_CLANG_LIB(clangSerialization) | ||
FIND_AND_ADD_CLANG_LIB(clangTooling) | ||
FIND_AND_ADD_CLANG_LIB(clangStaticAnalyzerCheckers) | ||
FIND_AND_ADD_CLANG_LIB(clangStaticAnalyzerCore) | ||
FIND_AND_ADD_CLANG_LIB(clangStaticAnalyzerFrontend) | ||
FIND_AND_ADD_CLANG_LIB(clangSema) | ||
FIND_AND_ADD_CLANG_LIB(clangRewriteCore) | ||
# clang 3.7 | ||
FIND_AND_ADD_CLANG_LIB(clangRewriteFrontend) | ||
FIND_AND_ADD_CLANG_LIB(clangASTMatchers) | ||
FIND_AND_ADD_CLANG_LIB(clangToolingCore) | ||
|
||
|
||
|
||
|
||
|
||
MESSAGE(STATUS "Clang libs: " ${CLANG_LIBS}) | ||
|
||
if(CLANG_LIBS) | ||
set(CLANG_FOUND TRUE) | ||
endif(CLANG_LIBS) | ||
|
||
if(CLANG_FOUND) | ||
message(STATUS "Found Clang: ${CLANG_INCLUDE_DIRS}") | ||
else(CLANG_FOUND) | ||
if(CLANG_FIND_REQUIRED) | ||
message(FATAL_ERROR "Could NOT find Clang") | ||
endif(CLANG_FIND_REQUIRED) | ||
endif(CLANG_FOUND) | ||
|
||
endif (NOT LLVM_INCLUDE_DIR OR NOT LLVM_LIB_DIR) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Detect LLVM and set various variable to link against the different component of LLVM | ||
# | ||
# NOTE: This is a modified version of the module originally found in the OpenGTL project | ||
# at www.opengtl.org | ||
# | ||
# LLVM_BIN_DIR : directory with LLVM binaries | ||
# LLVM_LIB_DIR : directory with LLVM library | ||
# LLVM_INCLUDE_DIR : directory with LLVM include | ||
# | ||
# LLVM_COMPILE_FLAGS : compile flags needed to build a program using LLVM headers | ||
# LLVM_LDFLAGS : ldflags needed to link | ||
# LLVM_LIBS_CORE : ldflags needed to link against a LLVM core library | ||
# LLVM_LIBS_JIT : ldflags needed to link against a LLVM JIT | ||
# LLVM_LIBS_JIT_OBJECTS : objects you need to add to your source when using LLVM JIT | ||
|
||
if (LLVM_INCLUDE_DIR) | ||
set(LLVM_FOUND TRUE) | ||
else (LLVM_INCLUDE_DIR) | ||
|
||
set(CONFIG_NAME "llvm-config") | ||
if (NOT "${LLVM_CONFIG_EXECUTABLE}" STREQUAL "") | ||
set(CONFIG_NAME "${LLVM_CONFIG_EXECUTABLE}") | ||
unset(LLVM_CONFIG_EXECUTABLE CACHE) | ||
endif() | ||
find_program(LLVM_CONFIG_EXECUTABLE | ||
NAMES "${CONFIG_NAME}" | ||
PATHS | ||
/opt/local/bin | ||
) | ||
|
||
MACRO(FIND_LLVM_LIBS LLVM_CONFIG_EXECUTABLE _libname_ LIB_VAR OBJECT_VAR) | ||
exec_program( ${LLVM_CONFIG_EXECUTABLE} ARGS --libs ${_libname_} OUTPUT_VARIABLE ${LIB_VAR} ) | ||
STRING(REGEX MATCHALL "[^ ]*[.]o[ $]" ${OBJECT_VAR} ${${LIB_VAR}}) | ||
SEPARATE_ARGUMENTS(${OBJECT_VAR}) | ||
STRING(REGEX REPLACE "[^ ]*[.]o[ $]" "" ${LIB_VAR} ${${LIB_VAR}}) | ||
ENDMACRO(FIND_LLVM_LIBS) | ||
|
||
|
||
exec_program(${LLVM_CONFIG_EXECUTABLE} ARGS --bindir OUTPUT_VARIABLE LLVM_BIN_DIR ) | ||
exec_program(${LLVM_CONFIG_EXECUTABLE} ARGS --libdir OUTPUT_VARIABLE LLVM_LIB_DIR ) | ||
#MESSAGE(STATUS "LLVM lib dir: " ${LLVM_LIB_DIR}) | ||
exec_program(${LLVM_CONFIG_EXECUTABLE} ARGS --includedir OUTPUT_VARIABLE LLVM_INCLUDE_DIR ) | ||
|
||
|
||
exec_program(${LLVM_CONFIG_EXECUTABLE} ARGS --cxxflags OUTPUT_VARIABLE LLVM_COMPILE_FLAGS ) | ||
string(REPLACE ${LLVM_INCLUDE_DIR} "\"LLVM_INCLUDE_DIR\"" LLVM_COMPILE_FLAGS "${LLVM_COMPILE_FLAGS}") | ||
MESSAGE(STATUS "LLVM CXX flags: " ${LLVM_COMPILE_FLAGS}) | ||
execute_process(COMMAND ${LLVM_CONFIG_EXECUTABLE} --ldflags OUTPUT_VARIABLE LLVM_LDFLAGS OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) | ||
#--system-libs is new in llvm 3.5 | ||
execute_process(COMMAND ${LLVM_CONFIG_EXECUTABLE} --system-libs OUTPUT_VARIABLE LLVM_LDFLAGS2 OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET) | ||
string(REPLACE "\n" " " LLVM_LDFLAGS "${LLVM_LDFLAGS} ${LLVM_LDFLAGS2}") | ||
string(STRIP ${LLVM_LDFLAGS} LLVM_LDFLAGS) | ||
MESSAGE(STATUS "LLVM LD flags: " ${LLVM_LDFLAGS}) | ||
exec_program(${LLVM_CONFIG_EXECUTABLE} ARGS --libnames OUTPUT_VARIABLE LLVM_LIBS_CORE ) | ||
string(REPLACE " " ";" LLVM_LIBS_CORE ${LLVM_LIBS_CORE}) | ||
MESSAGE(STATUS "LLVM core libs: " ${LLVM_LIBS_CORE}) | ||
|
||
if(LLVM_INCLUDE_DIR) | ||
set(LLVM_FOUND TRUE) | ||
endif(LLVM_INCLUDE_DIR) | ||
|
||
if(LLVM_FOUND) | ||
message(STATUS "Found LLVM: ${LLVM_INCLUDE_DIR}") | ||
else(LLVM_FOUND) | ||
if(LLVM_FIND_REQUIRED) | ||
message(FATAL_ERROR "Could NOT find LLVM") | ||
endif(LLVM_FIND_REQUIRED) | ||
endif(LLVM_FOUND) | ||
|
||
endif (LLVM_INCLUDE_DIR) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# !!!!! | ||
# README | ||
# | ||
# You have to be building MetaCPPCLI or specify the location of the executable like this: | ||
# | ||
# set(META_CPP_BIN "Tools/MetaCPPCLI.exe") | ||
# | ||
# !!!!! | ||
|
||
# This should be called after configuring the whole project | ||
# Example | ||
# meta_generate(MetaTest "ToReflect.hpp" "Generated.hpp" "Generated.cpp") | ||
macro(meta_generate PROJECT_NAME IN_SOURCE OUT_HEADER OUT_SOURCE) | ||
message("Project ${PROJECT_NAME} will be reflected:") | ||
|
||
# get the include directories | ||
get_property(INC_DIRECTORIES TARGET ${PROJECT_NAME} PROPERTY INCLUDE_DIRECTORIES) | ||
|
||
# flags that will be passed to the tool | ||
set(FLAGS " ") | ||
|
||
# add the include directories into the flags | ||
message(" Included directories:") | ||
foreach (DIRECTORY ${INC_DIRECTORIES}) | ||
message(" - ${DIRECTORY}") | ||
set(FLAGS ${FLAGS} "\\-I${DIRECTORY}") | ||
endforeach () | ||
|
||
# get the absolute path to the files | ||
get_filename_component(IN_SOURCE_PATH "${IN_SOURCE}" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") | ||
get_filename_component(OUT_HEADER_PATH "${OUT_HEADER}" REALPATH BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") | ||
get_filename_component(OUT_SOURCE_PATH "${OUT_SOURCE}" REALPATH BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}") | ||
|
||
message(" Source in: ${IN_SOURCE_PATH}") | ||
message(" Header out: ${OUT_HEADER_PATH}") | ||
message(" Source out: ${OUT_SOURCE_PATH}") | ||
|
||
# get the executable absolute path | ||
if(TARGET MetaCPPCLI) | ||
# we're compiling the cli | ||
add_dependencies(${PROJECT_NAME} MetaCPPCLI) | ||
set(META_CPP_EXE "$<TARGET_FILE:MetaCPPCLI>") | ||
else() | ||
# we'll fallback to a precompiled | ||
get_filename_component(META_CPP_EXE "${META_CPP_BIN}" REALPATH BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") | ||
endif() | ||
|
||
# command | ||
add_custom_command( | ||
TARGET ${PROJECT_NAME} | ||
PRE_BUILD | ||
COMMAND call "${META_CPP_EXE}" | ||
"${IN_SOURCE_PATH}" | ||
-out-header "${OUT_HEADER_PATH}" | ||
-out-source "${OUT_SOURCE_PATH}" | ||
-flags "${FLAGS}" | ||
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | ||
) | ||
endmacro() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
cmake_minimum_required (VERSION 2.8) | ||
project(MetaCPP-Examples) | ||
|
||
add_subdirectory(../MetaCPP-CLI MetaCPP-CLI) | ||
|
||
add_subdirectory(Generation) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
cmake_minimum_required (VERSION 2.8) | ||
|
||
|
||
add_executable(Example-Generation main.cpp) | ||
|
||
target_link_libraries(Example-Generation MetaCPP) | ||
|
||
include(../../CMake/MetaPrebuild.cmake) | ||
meta_generate(Example-Generation "test.hpp" "Generated.hpp" "Generated.cpp") |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <MetaCPP/Storage.hpp> | ||
|
||
#include "test.hpp" | ||
|
||
#include <iostream> | ||
|
||
int main() { | ||
|
||
return 0; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
struct Point { | ||
double x, y; | ||
}; | ||
|
||
class Base { | ||
protected: | ||
int a; | ||
double b; | ||
public: | ||
float method(short c) { | ||
return a + c; | ||
} | ||
}; | ||
|
||
class Derived : public Base { | ||
public: | ||
long method(int d) { | ||
return a + b + d; | ||
} | ||
protected: | ||
Point derived_point; | ||
char c; | ||
int e, f; | ||
}; |
Oops, something went wrong.