Group CMake targets into folders

CMake uses the `FOLDER` property to group the generated Visual Studio
projects into solution folders.

Removed bond_ and documentation_ prefix from project names. The prefixes
were intended to group projects by name which is no longer necessary.
This commit is contained in:
Adam Sapek 2015-10-27 10:49:44 -07:00
Родитель ab71ef89a3
Коммит a4201850a6
21 изменённых файлов: 131 добавлений и 94 удалений

Просмотреть файл

@ -76,8 +76,8 @@ script:
- if [ "$BOND_LANG" == "cs" ]; then make --jobs 2 DESTDIR=$HOME install; fi
- if [ "$BOND_LANG" == "cs" ]; then export BOND_COMPILER_PATH=$HOME/usr/local/bin; fi
- if [[ $BOND_LANG == cpp* ]]; then make --jobs 2 check; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then export BOND_PYTHON_TARGETS="bond_python_unit_test python_extension" BOND_PYTHON_TESTS=bond_python_unit_test; fi
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then export BOND_PYTHON_TARGETS="bond_python_compatibility_test bond_python_unit_test python_extension bond_compatibility_test" BOND_PYTHON_TESTS=".*python.*"; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then export BOND_PYTHON_TARGETS="python_unit_test python_extension" BOND_PYTHON_TESTS=python_unit_test; fi
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then export BOND_PYTHON_TARGETS="python_compatibility_test python_unit_test python_extension compatibility_test" BOND_PYTHON_TESTS=".*python.*"; fi
- if [[ $BOND_LANG == py* ]]; then make $BOND_PYTHON_TARGETS; fi
- if [[ $BOND_LANG == py* ]]; then ctest --tests-regex $BOND_PYTHON_TESTS --output-on-failure; fi
- if [ "$BOND_GHC_VERSION" != "" ]; then make gbc-tests; fi

Просмотреть файл

@ -22,9 +22,9 @@ include (PythonTest)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -C ${CMAKE_CFG_INTDIR} --output-on-failure)
add_subdirectory (compiler)
add_subfolder (compiler "compiler")
add_subdirectory (cpp)
add_subdirectory (doc)
add_subfolder (doc "doc")
add_python_subdirectory (python)
add_subdirectory (examples)

Просмотреть файл

@ -177,7 +177,7 @@
if ($env:BOND_BUILD -eq "Python") {
cmake --build . --target bond_python_unit_test -- /verbosity:minimal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
cmake --build . --target python_unit_test -- /verbosity:minimal /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
}
@ -201,7 +201,7 @@
if ($env:BOND_BUILD -eq "Python") {
ctest -C Debug --tests-regex bond_python_unit_test --output-on-failure
ctest -C Debug --tests-regex python_unit_test --output-on-failure
}

Просмотреть файл

@ -1,4 +1,5 @@
include (CMakeParseArguments)
include (Folders)
#
# add_bond_codegen (file.bond [file2.bond ...]
@ -54,6 +55,7 @@ function (add_bond_codegen)
add_custom_target (${arg_TARGET}
DEPENDS ${outputs}
SOURCES ${inputs})
add_target_to_folder(${arg_TARGET})
endif()
endfunction()
@ -77,6 +79,7 @@ function (add_bond_executable target)
add_bond_codegen (${schemas})
endif()
add_executable (${ARGV} ${sources})
add_target_to_folder(${target})
target_link_libraries (${target} PRIVATE
bond
bond_apply)
@ -122,6 +125,7 @@ function (add_bond_python_module target)
list (INSERT ARGV 1 EXCLUDE_FROM_ALL)
python_add_module (${ARGV} ${sources})
add_dependencies (check ${target})
add_target_to_folder(${target})
target_link_libraries (${target} PRIVATE
bond
bond_apply
@ -137,4 +141,3 @@ function (add_bond_python_module target)
target_compile_definitions (${target} PRIVATE
-DBOOST_PYTHON_STATIC_LIB)
endfunction()

20
cmake/Folders.cmake Normal file
Просмотреть файл

@ -0,0 +1,20 @@
set_property (GLOBAL PROPERTY USE_FOLDERS On)
#
# Add the target to "current" folder
#
function (add_target_to_folder target)
set_property (GLOBAL APPEND PROPERTY bond_targets ${target})
endfunction()
#
# add_subfolder (subdirectory folder)
# similar to built-in add_subdirectory but groups targets in specified folder
#
macro (add_subfolder dir folder)
set_property (GLOBAL PROPERTY bond_targets)
add_subdirectory (${dir})
get_property (targets GLOBAL PROPERTY bond_targets)
set_target_properties (${targets} PROPERTIES FOLDER ${folder})
endmacro()

Просмотреть файл

@ -4,6 +4,7 @@ set (CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
include (CMakeParseArguments)
include (Folders)
# required Haskell components
find_package (Cabal 1.18.0.0 REQUIRED)
@ -31,6 +32,7 @@ function (add_cabal_build target)
SOURCES ${arg_SOURCES}
DEPENDS ${arg_DEPENDS}
${CMAKE_CURRENT_BINARY_DIR}/build/${target}/${target}${CMAKE_EXECUTABLE_SUFFIX})
add_target_to_folder(${target})
add_dependencies (${target} sandbox)
endfunction()
@ -91,6 +93,7 @@ add_custom_command (
add_custom_target (sandbox
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/cabal.sandbox.config)
add_target_to_folder(sandbox)
add_custom_command (
DEPENDS ${output}

Просмотреть файл

@ -1,7 +1,8 @@
# warning C4310: cast truncates constant value
cxx_add_compile_options(MSVC /wd4310)
add_subdirectory (compat)
add_subfolder (compat "tests/compat")
if (Boost_UNIT_TEST_FRAMEWORK_FOUND)
add_subdirectory (core)
add_subfolder (core "tests/unit_test/core")
endif()

Просмотреть файл

@ -1,6 +1,6 @@
cxx_add_compile_options(Clang -Wno-unused-value)
add_bond_executable (bond_compatibility_test EXCLUDE_FROM_ALL
add_bond_executable (compatibility_test EXCLUDE_FROM_ALL
${BOND_COMPAT_TEST_DIR}/schemas/compat.bond
${BOND_COMPAT_TEST_DIR}/schemas/compat2.bond
${BOND_COMPAT_TEST_DIR}/schemas/compat_no_generics.bond
@ -9,15 +9,15 @@ add_bond_executable (bond_compatibility_test EXCLUDE_FROM_ALL
compat.cpp
serialization.cpp)
add_dependencies (check bond_compatibility_test)
add_dependencies (check compatibility_test)
target_compile_definitions (bond_compatibility_test PRIVATE
target_compile_definitions (compatibility_test PRIVATE
-DBOND_COMPACT_BINARY_PROTOCOL
-DBOND_SIMPLE_BINARY_PROTOCOL
-DBOND_FAST_BINARY_PROTOCOL
-DBOND_SIMPLE_JSON_PROTOCOL)
target_use_cxx11 (bond_compatibility_test)
target_use_cxx11 (compatibility_test)
# disable generation of debug symbols to speed up build
no_pdb()
@ -26,7 +26,7 @@ function (add_compat_test test)
add_test (
NAME compatibility_${test}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMAND bond_compatibility_test ${test} -d ${BOND_COMPAT_TEST_DIR}/data/compat.${test}.dat expected.cpp.${test} deserialized.cpp.${test})
COMMAND compatibility_test ${test} -d ${BOND_COMPAT_TEST_DIR}/data/compat.${test}.dat expected.cpp.${test} deserialized.cpp.${test})
if (BOND_CSHARP_COMPAT_TEST)
add_test (
@ -34,7 +34,7 @@ function (add_compat_test test)
COMMAND
${CMAKE_COMMAND}
-DCSHARP_COMPAT=${BOND_CSHARP_COMPAT_TEST}
-DBOND_COMPAT=$<TARGET_FILE:bond_compatibility_test>
-DBOND_COMPAT=$<TARGET_FILE:compatibility_test>
-DCOMPAT_DATA=${BOND_COMPAT_TEST_DIR}/data
-DTEST=${test}
-P ${CMAKE_CURRENT_SOURCE_DIR}/compat.cmake

Просмотреть файл

@ -1,11 +1,12 @@
function (add_unit_test_library name)
list (INSERT ARGV 1 EXCLUDE_FROM_ALL)
add_library (${ARGV})
add_target_to_folder (${name})
add_dependencies (${name}
bond
bond_unit_test_codegen1
bond_unit_test_codegen2
bond_unit_test_codegen3)
unit_test_codegen1
unit_test_codegen2
unit_test_codegen3)
target_include_directories (${name} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})
@ -17,11 +18,11 @@ function (add_unit_test_library name)
-DBOND_SIMPLE_JSON_PROTOCOL
-DBOOST_ENABLE_ASSERT_HANDLER)
target_use_cxx11 (${name})
target_link_libraries (${name} INTERFACE bond_unit_test_idl bond)
target_link_libraries (bond_unit_test PRIVATE ${name})
target_link_libraries (${name} INTERFACE unit_test_idl bond)
target_link_libraries (unit_test PRIVATE ${name})
endfunction()
add_bond_codegen (TARGET bond_unit_test_codegen2
add_bond_codegen (TARGET unit_test_codegen2
unit_test_core.bond
apply_test.bond
import_test1.bond
@ -33,7 +34,7 @@ add_bond_codegen (TARGET bond_unit_test_codegen2
OPTIONS
--header=\\\"custom_protocols.h\\\")
add_bond_codegen (TARGET bond_unit_test_codegen1
add_bond_codegen (TARGET unit_test_codegen1
unit_test.bond
OPTIONS
--using=\"static_string=std::array<char, {0}>\"
@ -42,7 +43,7 @@ add_bond_codegen (TARGET bond_unit_test_codegen1
--header=\\\"custom_protocols.h\\\"
--header=\\\"container_extensibility.h\\\")
add_bond_codegen (TARGET bond_unit_test_codegen3
add_bond_codegen (TARGET unit_test_codegen3
allocator_test.bond
OPTIONS
--using=\"Vector=std::vector<{0}, detail::TestAllocator<{0}> >\"
@ -50,15 +51,16 @@ add_bond_codegen (TARGET bond_unit_test_codegen3
--header=\\\"allocators.h\\\"
--allocator=TestAllocator)
add_bond_test (bond_unit_test init.cpp)
add_bond_test (unit_test init.cpp)
target_use_cxx11 (bond_unit_test)
target_use_cxx11 (unit_test)
add_library (bond_unit_test_main EXCLUDE_FROM_ALL main.cpp)
add_library (unit_test_main EXCLUDE_FROM_ALL main.cpp)
add_target_to_folder (unit_test_main)
target_link_libraries (bond_unit_test PRIVATE
target_link_libraries (unit_test PRIVATE
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}
bond_unit_test_main)
unit_test_main)
# Full unit test is too big, .pdb files exceed compiler limit;
# Since debugging such large executable is not practical anyways,
@ -67,10 +69,10 @@ target_link_libraries (bond_unit_test PRIVATE
no_pdb()
# split across multiple libraries to parallelize build
add_unit_test_library (bond_unit_test_idl
add_unit_test_library (unit_test_idl
idl.cpp)
add_unit_test_library (bond_unit_test_lib1
add_unit_test_library (unit_test_lib1
skip_id_tests.cpp
skip_type_tests.cpp
inheritance.cpp
@ -84,7 +86,7 @@ add_unit_test_library (bond_unit_test_lib1
cmdargs.cpp
metadata_tests.cpp)
add_unit_test_library (bond_unit_test_lib2
add_unit_test_library (unit_test_lib2
json_tests.cpp
pass_through.cpp
associative_container_extensibility.cpp
@ -92,14 +94,14 @@ add_unit_test_library (bond_unit_test_lib2
apply_init.cpp
may_omit_fields.cpp)
add_unit_test_library (bond_unit_test_lib3
add_unit_test_library (unit_test_lib3
numeric_convertions.cpp)
add_unit_test_library (bond_unit_test_lib4
add_unit_test_library (unit_test_lib4
generics_test.cpp
merge_test.cpp)
add_unit_test_library (bond_unit_test_lib5
add_unit_test_library (unit_test_lib5
list_tests.cpp
serialization_test.cpp
allocator_test.cpp
@ -107,7 +109,7 @@ add_unit_test_library (bond_unit_test_lib5
basic_type_lists.cpp
nullable.cpp)
add_unit_test_library (bond_unit_test_lib6
add_unit_test_library (unit_test_lib6
marshal.cpp
container_extensibility.cpp
basic_type_map.cpp

Просмотреть файл

@ -5,6 +5,7 @@ set (CMAKE_MODULE_PATH
include (CMakeParseArguments)
include (HaskellUtil)
include (Folders)
# build the compiler when doc directory is build by itself
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
@ -55,10 +56,11 @@ function (add_pandoc_markdown)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${file} ${PANDOC_EXECUTABLE})
endforeach()
add_custom_target ("documentation_${name}"
add_custom_target (${name}
DEPENDS ${outputs}
SOURCES ${sources})
add_dependencies (documentation "documentation_${name}")
add_target_to_folder (${name})
add_dependencies (documentation ${name})
endfunction()
add_custom_command(
@ -71,6 +73,8 @@ add_custom_command(
add_custom_target (documentation
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/html/manual/gbc.html")
add_target_to_folder (documentation)
find_haskell_program (pandoc)
if (Haskell_PANDOC_EXECUTABLE)
@ -126,9 +130,11 @@ if (Doxygen_EXECUTABLE)
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
DEPENDS ${doxygen_sources})
add_custom_target (documentation_cpp_reference
add_custom_target (cpp_reference
DEPENDS "${doxygen_output_dir}/cpp/index.html"
SOURCES ${doxygen_sources})
add_dependencies (documentation documentation_cpp_reference)
add_target_to_folder (cpp_reference)
add_dependencies (documentation cpp_reference)
endif()

Просмотреть файл

@ -1 +1 @@
add_subdirectory (core)
add_subfolder (core "examples/core")

Просмотреть файл

@ -11,7 +11,7 @@ add_test (
COMMAND
${CMAKE_COMMAND}
-DBF=$<TARGET_FILE:bf>
-DBOND_COMPAT=$<TARGET_FILE:bond_compatibility_test>
-DBOND_COMPAT=$<TARGET_FILE:compatibility_test>
-DCOMPAT_DATA=${BOND_COMPAT_TEST_DIR}/data
-P ${CMAKE_CURRENT_SOURCE_DIR}/bf_test.cmake
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})

Просмотреть файл

@ -6,6 +6,8 @@ add_library (static_library_lib EXCLUDE_FROM_ALL
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/static_library_types.cpp
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/static_library_apply.cpp)
add_target_to_folder (static_library_lib)
target_link_libraries (static_library_lib PUBLIC
bond)

Просмотреть файл

@ -1,2 +1,2 @@
use_cxx11 ()
add_subdirectory (core)
add_subfolder (core "examples/python/core")

Просмотреть файл

@ -1,2 +1,2 @@
add_subdirectory (core)
add_subdirectory (compat)
add_subfolder (core "tests/python/unit_test/core")
add_subfolder (compat "tests/python/compat")

Просмотреть файл

@ -1,11 +1,11 @@
add_bond_python_module (bond_python_compatibility_test
add_bond_python_module (python_compatibility_test
${BOND_COMPAT_TEST_DIR}/schemas/compat.bond
${BOND_COMPAT_TEST_DIR}/schemas/compat2.bond
${BOND_COMPAT_TEST_DIR}/schemas/compat_common.bond
compat.cpp
compat.py)
target_compile_definitions (bond_python_compatibility_test PRIVATE
target_compile_definitions (python_compatibility_test PRIVATE
-DBOND_COMPACT_BINARY_PROTOCOL)
# disable generation of debug symbols to speed up build
@ -17,8 +17,8 @@ function (add_python_compat_test test)
COMMAND
${CMAKE_COMMAND}
-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
-DPYTHON_COMPAT=$<TARGET_FILE_DIR:bond_python_compatibility_test>
-DBOND_COMPAT=$<TARGET_FILE:bond_compatibility_test>
-DPYTHON_COMPAT=$<TARGET_FILE_DIR:python_compatibility_test>
-DBOND_COMPAT=$<TARGET_FILE:compatibility_test>
-DCOMPAT_DATA=${BOND_COMPAT_TEST_DIR}/data
-DTEST=${test}
-DSOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}

Просмотреть файл

@ -1,7 +1,7 @@
#include "compat_reflection.h"
#include <bond/python/struct.h>
BOOST_PYTHON_MODULE(bond_python_compatibility_test)
BOOST_PYTHON_MODULE(python_compatibility_test)
{
using namespace unittest::compat;

Просмотреть файл

@ -1,5 +1,5 @@
from __future__ import print_function
import bond_python_compatibility_test as test
import python_compatibility_test as test
import sys, getopt
def schema(input_, output):

Просмотреть файл

@ -1,15 +1,15 @@
add_bond_python_module (bond_python_unit_test
add_bond_python_module (python_unit_test
unit_test.cpp
unit_test.bond
unit_test.py)
target_compile_definitions (bond_python_unit_test PRIVATE
target_compile_definitions (python_unit_test PRIVATE
-DBOND_COMPACT_BINARY_PROTOCOL)
# disable generation of debug symbols to speed up build
no_pdb()
add_python_test (
NAME bond_python_unit_test
MODULE bond_python_unit_test
NAME python_unit_test
MODULE python_unit_test
SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/unit_test.py)

Просмотреть файл

@ -1,7 +1,7 @@
#include "unit_test_reflection.h"
#include <bond/python/struct.h>
BOOST_PYTHON_MODULE(bond_python_unit_test)
BOOST_PYTHON_MODULE(python_unit_test)
{
using namespace unittest;
using namespace bond::python;

Просмотреть файл

@ -3,8 +3,8 @@ import random
import string
import functools
import sys
from bond_python_unit_test import Serialize, Deserialize, Marshal, Unmarshal, GetRuntimeSchema
import bond_python_unit_test as test
from python_unit_test import Serialize, Deserialize, Marshal, Unmarshal, GetRuntimeSchema
import python_unit_test as test
def atleast_python3():
return sys.version_info[0] >= 3