added IDE support for cmake
This commit is contained in:
parent
cd6b72b492
commit
0d7d1a2b63
|
@ -39,6 +39,8 @@ endif()
|
|||
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
|
||||
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/lib)
|
||||
|
||||
set(OPEN_FOR_IDE OFF CACHE BOOL "Open this in an IDE (won't compile/link)")
|
||||
|
||||
################################################################################
|
||||
# Packages used for bindings
|
||||
################################################################################
|
||||
|
|
23
README.md
23
README.md
|
@ -125,6 +125,29 @@ directory. This can than be used for tools like
|
|||
code-completion and code navigation in flow. It is not yet perfect (it will show
|
||||
a few errors) but we are constantly working on improving the developement experience.
|
||||
|
||||
### Using IDEs
|
||||
|
||||
CMake has built in support for a number of popular IDEs. However, because flow
|
||||
files are precompiled with the actor compiler, an IDE will not be very useful as
|
||||
a user will only be presented with the generated code - which is not what she
|
||||
wants to edit and get IDE features for.
|
||||
|
||||
The good news is, that it is possible to generate project files for edititing
|
||||
flow with a supported IDE. There is a cmake option called `OPEN_FOR_IDE` which
|
||||
will generate a project which can be opened in an IDE for editing. You won't be
|
||||
able to build this project, but you will be able to edit the files and get most
|
||||
edit and navigation features your IDE supports.
|
||||
|
||||
For example, if you want to use XCode to make changes to FoundationDB you can
|
||||
create a XCode-project with the following command:
|
||||
|
||||
```
|
||||
cmake -G Xcode -DOPEN_FOR_IDE=ON <FDB_SOURCE_DIRECTORY>
|
||||
```
|
||||
|
||||
You should create a second build-directory which you will use for building
|
||||
(probably with make or ninja) and debugging.
|
||||
|
||||
### Linux
|
||||
|
||||
There are no special requirements for Linux. However, we are currently working
|
||||
|
|
|
@ -4,7 +4,6 @@ set(USE_VALGRIND OFF CACHE BOOL "Compile for valgrind usage")
|
|||
set(USE_GOLD_LINKER OFF CACHE BOOL "Use gold linker")
|
||||
set(ALLOC_INSTRUMENTATION OFF CACHE BOOL "Instrument alloc")
|
||||
set(WITH_UNDODB OFF CACHE BOOL "Use rr or undodb")
|
||||
set(OPEN_FOR_IDE OFF CACHE BOOL "Open this in an IDE (won't compile/link)")
|
||||
set(FDB_RELEASE OFF CACHE BOOL "This is a building of a final release")
|
||||
|
||||
add_compile_options(-DCMAKE_BUILD)
|
||||
|
|
|
@ -11,7 +11,7 @@ generated. This property is set through the add_flow_target function.")
|
|||
|
||||
function(generate_coverage_xml)
|
||||
if(NOT (${ARGC} EQUAL "1"))
|
||||
message(ERROR "generate_coverage_xml expects one argument")
|
||||
message(FATAL_ERROR "generate_coverage_xml expects one argument")
|
||||
endif()
|
||||
set(target_name ${ARGV0})
|
||||
get_target_property(sources ${target_name} SOURCE_FILES)
|
||||
|
@ -75,12 +75,31 @@ function(add_flow_target)
|
|||
set(multiValueArgs SRCS COVERAGE_FILTER_OUT DISABLE_ACTOR_WITHOUT_WAIT_WARNING)
|
||||
cmake_parse_arguments(AFT "${options}" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")
|
||||
if(NOT AFT_NAME)
|
||||
message(ERROR "add_flow_target requires option NAME")
|
||||
message(FATAL_ERROR "add_flow_target requires option NAME")
|
||||
endif()
|
||||
if(NOT AFT_SRCS)
|
||||
message(ERROR "No sources provided")
|
||||
message(FATAL_ERROR "No sources provided")
|
||||
endif()
|
||||
foreach(src IN LISTS AFT_SRCS AFT_DISABLE_ACTOR_WITHOUT_WAIT_WARNING)
|
||||
if(OPEN_FOR_IDE)
|
||||
set(sources ${AFT_SRCS} ${AFT_DISABLE_ACTOR_WRITHOUT_WAIT_WARNING})
|
||||
if(AFT_EXECUTABLE)
|
||||
set(target_type exec)
|
||||
add_executable(${AFT_NAME} ${sources})
|
||||
endif()
|
||||
if(AFT_STATIC_LIBRARY)
|
||||
if(target_type)
|
||||
message(FATAL_ERROR "add_flow_target can only be of one type")
|
||||
endif()
|
||||
add_library(${AFT_NAME} STATIC ${sources})
|
||||
endif()
|
||||
if(AFT_DYNAMIC_LIBRARY)
|
||||
if(target_type)
|
||||
message(FATAL_ERROR "add_flow_target can only be of one type")
|
||||
endif()
|
||||
add_library(${AFT_NAME} DYNAMIC ${sources})
|
||||
endif()
|
||||
else()
|
||||
foreach(src IN LISTS AFT_SRCS AFT_DISABLE_ACTOR_WITHOUT_WAIT_WARNING)
|
||||
if(${src} MATCHES ".*\\.actor\\.(h|cpp)")
|
||||
list(APPEND actors ${src})
|
||||
if(${src} MATCHES ".*\\.h")
|
||||
|
@ -108,8 +127,8 @@ function(add_flow_target)
|
|||
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${src}" actorcompiler
|
||||
COMMENT "Compile actor: ${src}")
|
||||
endif()
|
||||
else()
|
||||
list(APPEND sources ${src})
|
||||
else()
|
||||
list(APPEND sources ${src})
|
||||
endif()
|
||||
endforeach()
|
||||
if(AFT_EXECUTABLE)
|
||||
|
@ -128,18 +147,13 @@ function(add_flow_target)
|
|||
endif()
|
||||
add_library(${AFT_NAME} DYNAMIC ${sources})
|
||||
endif()
|
||||
if(AFT_OBJECT_LIBRARY)
|
||||
if(target_type)
|
||||
message(FATAL_ERROR "add_flow_target can only be of one type")
|
||||
endif()
|
||||
add_library(${AFT_NAME} OBJECT ${sources})
|
||||
|
||||
set_property(TARGET ${AFT_NAME} PROPERTY SOURCE_FILES ${AFT_SRCS})
|
||||
set_property(TARGET ${AFT_NAME} PROPERTY COVERAGE_FILTERS ${AFT_SRCS})
|
||||
|
||||
add_custom_target(${AFT_NAME}_actors DEPENDS ${generated_files})
|
||||
add_dependencies(${AFT_NAME} ${AFT_NAME}_actors)
|
||||
generate_coverage_xml(${AFT_NAME})
|
||||
endif()
|
||||
|
||||
set_property(TARGET ${AFT_NAME} PROPERTY SOURCE_FILES ${AFT_SRCS})
|
||||
set_property(TARGET ${AFT_NAME} PROPERTY COVERAGE_FILTERS ${AFT_SRCS})
|
||||
|
||||
add_custom_target(${AFT_NAME}_actors DEPENDS ${generated_files})
|
||||
add_dependencies(${AFT_NAME} ${AFT_NAME}_actors)
|
||||
generate_coverage_xml(${AFT_NAME})
|
||||
target_include_directories(${AFT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
|
||||
endfunction()
|
||||
|
|
Loading…
Reference in New Issue