Commit 0793464d authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'ghs_custom'

2bae6a13 GHS: Update tests and notes
3b415c60 GHS: Update ExternalProject for GHS tools
83c47ef5 GHS: Update project layout to accommodate gbuild inconsistencies
5d2e1404 GHS: Update project layout to build targets correctly
b6bfa7ee GHS: Support add_dependencies() command
39ee9718 GHS: Support add_custom_target() command
8d3dad9a GHS: Support add_custom_command( OUTPUT ) signature
37acc9e2 GHS: Update custom command build events
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Narendhar Manimohan's avatarNarendhar Manimohan <narendhar15@gmail.com>
Merge-request: !3119
parents e2128e11 2bae6a13
ghs_custom_commands
-------------------
* The :generator:`Green Hills MULTI` generator now supports
:command:`add_custom_command` and :command:`add_custom_target`
......@@ -422,6 +422,10 @@ External Project Definition
different behavior depending on whether the build starts from a fresh
build directory or re-uses previous build contents.
If the CMake generator is the ``Green Hills MULTI`` and not overridden then
the orginal projects settings for the GHS toolset and target system
customization cache variables are propagated into the external project.
``SOURCE_SUBDIR <dir>``
When no ``CONFIGURE_COMMAND`` option is specified, the configure step
assumes the external project has a ``CMakeLists.txt`` file at the top of
......@@ -2850,18 +2854,6 @@ function(_ep_extract_configure_command var name)
set(has_cmake_cache_default_args 1)
endif()
if(has_cmake_cache_args OR has_cmake_cache_default_args)
set(_ep_cache_args_script "<TMP_DIR>/${name}-cache-$<CONFIG>.cmake")
if(has_cmake_cache_args)
_ep_command_line_to_initial_cache(script_initial_cache_force "${cmake_cache_args}" 1)
endif()
if(has_cmake_cache_default_args)
_ep_command_line_to_initial_cache(script_initial_cache_default "${cmake_cache_default_args}" 0)
endif()
_ep_write_initial_cache(${name} "${_ep_cache_args_script}" "${script_initial_cache_force}${script_initial_cache_default}")
list(APPEND cmd "-C${_ep_cache_args_script}")
endif()
get_target_property(cmake_generator ${name} _EP_CMAKE_GENERATOR)
get_target_property(cmake_generator_instance ${name} _EP_CMAKE_GENERATOR_INSTANCE)
get_target_property(cmake_generator_platform ${name} _EP_CMAKE_GENERATOR_PLATFORM)
......@@ -2882,6 +2874,16 @@ function(_ep_extract_configure_command var name)
list(APPEND cmd "-G${CMAKE_EXTRA_GENERATOR} - ${CMAKE_GENERATOR}")
else()
list(APPEND cmd "-G${CMAKE_GENERATOR}")
if("${CMAKE_GENERATOR}" MATCHES "Green Hills MULTI")
set(has_cmake_cache_default_args 1)
set(cmake_cache_default_args ${cmake_cache_default_args}
"-DGHS_TARGET_PLATFORM:STRING=${GHS_TARGET_PLATFORM}"
"-DGHS_PRIMARY_TARGET:STRING=${GHS_PRIMARY_TARGET}"
"-DGHS_TOOLSET_ROOT:STRING=${GHS_TOOLSET_ROOT}"
"-DGHS_OS_ROOT:STRING=${GHS_OS_ROOT}"
"-DGHS_OS_DIR:STRING=${GHS_OS_DIR}"
"-DGHS_BSP_NAME:STRING=${GHS_BSP_NAME}")
endif()
endif()
if(cmake_generator_platform)
message(FATAL_ERROR "Option CMAKE_GENERATOR_PLATFORM not allowed without CMAKE_GENERATOR.")
......@@ -2903,6 +2905,18 @@ function(_ep_extract_configure_command var name)
endif()
endif()
if(has_cmake_cache_args OR has_cmake_cache_default_args)
set(_ep_cache_args_script "<TMP_DIR>/${name}-cache-$<CONFIG>.cmake")
if(has_cmake_cache_args)
_ep_command_line_to_initial_cache(script_initial_cache_force "${cmake_cache_args}" 1)
endif()
if(has_cmake_cache_default_args)
_ep_command_line_to_initial_cache(script_initial_cache_default "${cmake_cache_default_args}" 0)
endif()
_ep_write_initial_cache(${name} "${_ep_cache_args_script}" "${script_initial_cache_force}${script_initial_cache_default}")
list(APPEND cmd "-C${_ep_cache_args_script}")
endif()
list(APPEND cmd "<SOURCE_DIR><SOURCE_SUBDIR>")
endif()
......
......@@ -9,7 +9,8 @@ static const char* GHS_TAG[] = { "[INTEGRITY Application]",
"[Project]",
"[Program]",
"[Reference]",
"[Subproject]" };
"[Subproject]",
"[Custom Target]" };
const char* GhsMultiGpj::GetGpjTag(Types gpjType)
{
......@@ -21,6 +22,7 @@ const char* GhsMultiGpj::GetGpjTag(Types gpjType)
case PROGRAM:
case REFERENCE:
case SUBPROJECT:
case CUSTOM_TARGET:
tag = GHS_TAG[gpjType];
break;
default:
......
......@@ -16,7 +16,8 @@ public:
PROJECT,
PROGRAM,
REFERENCE,
SUBPROJECT
SUBPROJECT,
CUSTOM_TARGET
};
static void WriteGpjTag(Types gpjType, std::ostream& fout);
......
This diff is collapsed.
......@@ -5,14 +5,14 @@
#include "cmGhsMultiGpj.h"
#include "cmTarget.h"
#include <iosfwd>
#include <map>
#include <set>
#include <string>
#include <vector>
class cmCustomCommand;
class cmCustomCommandGenerator;
class cmGeneratorTarget;
class cmGlobalGhsMultiGenerator;
class cmLocalGhsMultiGenerator;
......@@ -49,15 +49,23 @@ private:
void WriteIncludes(std::ostream& fout, const std::string& config,
const std::string& language);
void WriteTargetLinkLine(std::ostream& fout, std::string const& config);
void WriteCustomCommands(std::ostream& fout);
void WriteCustomCommandsHelper(
std::ostream& fout, std::vector<cmCustomCommand> const& commandsSet,
cmTarget::CustomCommandType commandType);
void WriteBuildEvents(std::ostream& fout);
void WriteBuildEventsHelper(std::ostream& fout,
const std::vector<cmCustomCommand>& ccv,
std::string const& name, std::string const& cmd);
void WriteCustomCommandsHelper(std::ostream& fout,
cmCustomCommandGenerator const& ccg);
void WriteCustomCommandLine(std::ostream& fout, std::string& fname,
cmCustomCommandGenerator const& ccg);
bool ComputeCustomCommandOrder(std::vector<cmSourceFile const*>& order);
bool VisitCustomCommand(std::set<cmSourceFile const*>& temp,
std::set<cmSourceFile const*>& perm,
std::vector<cmSourceFile const*>& order,
cmSourceFile const* sf);
void WriteSources(std::ostream& fout_proj);
void WriteSourceProperty(std::ostream& fout, const cmSourceFile* sf,
std::string const& propName,
std::string const& propFlag);
void WriteReferences(std::ostream& fout);
static void WriteObjectLangOverride(std::ostream& fout,
const cmSourceFile* sourceFile);
......@@ -71,7 +79,8 @@ private:
std::string TargetNameReal;
GhsMultiGpj::Types TagType;
std::string const Name;
std::string ConfigName; /* CMAKE_BUILD_TYPE */
std::string ConfigName; /* CMAKE_BUILD_TYPE */
bool const CmdWindowsShell; /* custom commands run in cmd.exe or /bin/sh */
};
#endif // ! cmGhsMultiTargetGenerator_h
This diff is collapsed.
......@@ -78,23 +78,7 @@ public:
// Write the common disclaimer text at the top of each build file.
void WriteFileHeader(std::ostream& fout);
// Target dependency sorting
class TargetSet : public std::set<cmGeneratorTarget const*>
{
};
class TargetCompare
{
std::string First;
public:
TargetCompare(std::string first)
: First(std::move(first))
{
}
bool operator()(cmGeneratorTarget const* l,
cmGeneratorTarget const* r) const;
};
class OrderedTargetDependSet;
const char* GetInstallTargetName() const override { return "install"; }
protected:
void Generate() override;
......@@ -111,18 +95,53 @@ private:
/* top-level project */
void OutputTopLevelProject(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
void WriteTopLevelProject(std::ostream& fout, cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
void WriteMacros(std::ostream& fout);
void WriteHighLevelDirectives(std::ostream& fout);
void WriteSubProjects(std::ostream& fout, cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
std::string trimQuotes(std::string const& str);
void WriteTopLevelProject(std::ostream& fout, cmLocalGenerator* root);
void WriteMacros(std::ostream& fout, cmLocalGenerator* root);
void WriteHighLevelDirectives(cmLocalGenerator* root, std::ostream& fout);
void WriteSubProjects(std::ostream& fout, std::string& all_target);
void WriteTargets(cmLocalGenerator* root);
void WriteProjectLine(std::ostream& fout, cmGeneratorTarget const* target,
cmLocalGenerator* root, std::string& rootBinaryDir);
void WriteCustomRuleBOD(std::ostream& fout);
void WriteCustomTargetBOD(std::ostream& fout);
void WriteAllTarget(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators,
std::string& all_target);
std::string TrimQuotes(std::string const& str);
std::string OsDir;
static const char* DEFAULT_BUILD_PROGRAM;
static const char* DEFAULT_TOOLSET_ROOT;
bool ComputeTargetBuildOrder(cmGeneratorTarget const* tgt,
std::vector<cmGeneratorTarget const*>& build);
bool ComputeTargetBuildOrder(std::vector<cmGeneratorTarget const*>& tgt,
std::vector<cmGeneratorTarget const*>& build);
bool VisitTarget(std::set<cmGeneratorTarget const*>& temp,
std::set<cmGeneratorTarget const*>& perm,
std::vector<cmGeneratorTarget const*>& order,
cmGeneratorTarget const* ti);
std::vector<cmGeneratorTarget const*> ProjectTargets;
// Target sorting
class TargetSet : public std::set<cmGeneratorTarget const*>
{
};
class TargetCompare
{
std::string First;
public:
TargetCompare(std::string first)
: First(std::move(first))
{
}
bool operator()(cmGeneratorTarget const* l,
cmGeneratorTarget const* r) const;
};
class OrderedTargetDependSet;
};
class cmGlobalGhsMultiGenerator::OrderedTargetDependSet
......
......@@ -2336,7 +2336,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
endmacro()
macro(add_test_GhsMulti_rename_install test_name)
add_test_GhsMulti( ${test_name} GhsMultiRenameInstall ${test_name}
"-DCMAKE_INSTALL_PREFIX=. -DRUN_TEST=${test_name}" ${CMAKE_CMAKE_COMMAND} -P ./cmake_install.cmake)
"-DCMAKE_INSTALL_PREFIX=. -DRUN_TEST=${test_name}" ${CMAKE_CMAKE_COMMAND} --build . --target install)
endmacro()
#unset ghs config variables
unset(ghs_config_name)
......@@ -2391,6 +2391,9 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
add_test_GhsMulti(compiler_options_kernel GhsMultiCompilerOptions Kernel "-DRUN_TEST=KERNEL_FLAGS -DRUN_TEST_BUILD_TYPE=DEBUG")
add_test_GhsMulti(try_compile_copy GhsMultiCopyFile "" "")
add_test_GhsMulti(ghs_platform GhsMultiPlatform "" "")
add_test_GhsMulti(custom_target GhsMultiCustomTarget "" "")
add_test_GhsMulti(dep_order GhsMultiDepOrder "" "")
add_test_GhsMulti(external_project GhsMultiExternalProject "" "")
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/GhsMulti/${ghs_config_name}")
#unset ghs config variables
unset(ghs_config_name)
......
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
project(test C)
# Tests assume no previous builds in the build directory
file(REMOVE_RECURSE ${CMAKE_CURRENT_BINARY_DIR}/build)
macro (test_output)
if (BUILD_OUTPUT STREQUAL EXPECTED_LINES )
message("Build OK")
else()
message("BUILD_OUTPUT")
foreach(Line IN LISTS BUILD_OUTPUT)
message("${Line}")
endforeach()
message("EXPECTED_LINES")
foreach(Line IN LISTS EXPECTED_LINES)
message("${Line}")
endforeach()
message(SEND_ERROR "Build KO")
endif()
endmacro()
message("Copy project")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.in
${CMAKE_CURRENT_BINARY_DIR}/src/CMakeLists.txt COPYONLY)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/exe1.c
${CMAKE_CURRENT_SOURCE_DIR}/lib1.c
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/src
)
message("Building ALL target")
try_compile(RESULT
${CMAKE_CURRENT_BINARY_DIR}/build
${CMAKE_CURRENT_BINARY_DIR}/src
test
CMAKE_FLAGS
-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}
OUTPUT_VARIABLE BUILD_OUTPUT)
message("Output from build:\n${BUILD_OUTPUT}")
#filter outputs
string(REPLACE "\r" "" BUILD_OUTPUT "${BUILD_OUTPUT}")
string(REPLACE "\n" ";" BUILD_OUTPUT "${BUILD_OUTPUT}")
list(FILTER BUILD_OUTPUT INCLUDE REGEX "^.*CT:")
unset(EXPECTED_LINES)
list(APPEND EXPECTED_LINES "CT: Processing target_empty_prebuild")
list(APPEND EXPECTED_LINES "CT: Processing target_empty_postbuild")
list(APPEND EXPECTED_LINES "CT: Processing target_cmd")
list(APPEND EXPECTED_LINES "CT: Processing target_cmd_prebuild")
list(APPEND EXPECTED_LINES "CT: Processing target_cmd_postbuild")
test_output()
message("Building target_update_files target")
try_compile(RESULT
${CMAKE_CURRENT_BINARY_DIR}/build
${CMAKE_CURRENT_BINARY_DIR}/src
test target_update_files
CMAKE_FLAGS
-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}
OUTPUT_VARIABLE BUILD_OUTPUT)
message("Output from build:\n${BUILD_OUTPUT}")
#filter outputs
string(REPLACE "\r" "" BUILD_OUTPUT "${BUILD_OUTPUT}")
string(REPLACE "\n" ";" BUILD_OUTPUT "${BUILD_OUTPUT}")
list(FILTER BUILD_OUTPUT INCLUDE REGEX "^.*CT:")
unset(EXPECTED_LINES)
list(APPEND EXPECTED_LINES "CT: Processing target_empty_prebuild")
list(APPEND EXPECTED_LINES "CT: Processing target_empty_postbuild")
list(APPEND EXPECTED_LINES "CT: generate C file another_file")
list(APPEND EXPECTED_LINES "CT: generate text file dependsA")
list(APPEND EXPECTED_LINES "CT: generate text file out_of_order_dep")
list(APPEND EXPECTED_LINES "CT: generate text files A, B, and C")
list(APPEND EXPECTED_LINES "CT: Processing target_update_files")
test_output()
message("Rerun target_update_files target")
try_compile(RESULT
${CMAKE_CURRENT_BINARY_DIR}/build
${CMAKE_CURRENT_BINARY_DIR}/src
test target_update_files
CMAKE_FLAGS
-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}
OUTPUT_VARIABLE BUILD_OUTPUT)
message("Output from build:\n${BUILD_OUTPUT}")
#filter outputs
string(REPLACE "\r" "" BUILD_OUTPUT "${BUILD_OUTPUT}")
string(REPLACE "\n" ";" BUILD_OUTPUT "${BUILD_OUTPUT}")
list(FILTER BUILD_OUTPUT INCLUDE REGEX "^.*CT:")
unset(EXPECTED_LINES)
list(APPEND EXPECTED_LINES "CT: Processing target_empty_prebuild")
list(APPEND EXPECTED_LINES "CT: Processing target_empty_postbuild")
list(APPEND EXPECTED_LINES "CT: generate text files A, B, and C")
list(APPEND EXPECTED_LINES "CT: Processing target_update_files")
test_output()
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
project(test C)
if(CMAKE_C_COMPILER_ID STREQUAL "GHS")
add_link_options("-non_shared")
endif()
add_library(lib1 lib1.c)
set(TEST_MISSING_TARGET_SRC 0)
set(TEST_MISSING_TARGET_DEP 0)
set(TEST_MISSING_DEP 0)
set(TEST_DEP_CYCLE 0)
add_executable(exe1 exe1.c)
target_link_libraries(exe1 lib1)
add_custom_target(target_cmd ALL
COMMAND ${CMAKE_COMMAND} -E echo "target_cmd" > target_cmd
COMMAND ${CMAKE_COMMAND} -E echo "target_cmd_extra" > target_cmd_extra.txt
BYPRODUCTS target_cmd target_cmd_extra.txt
COMMENT "CT: Processing target_cmd")
add_custom_command(TARGET target_cmd PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "target_cmd_prebuild" > target_cmd_prebuild.txt
BYPRODUCTS target_cmd_prebuild.txt
COMMENT "CT: Processing target_cmd_prebuild")
#event does not run for custom targets
add_custom_command(TARGET target_cmd PRE_LINK
COMMAND ${CMAKE_COMMAND} -E echo "executing target_cmd_prelink commands"
COMMAND ${CMAKE_COMMAND} -E echo "target_cmd_prelink" > target_cmd_prelink.txt
BYPRODUCTS target_cmd_prelink.txt
COMMENT "CT: Processing target_cmd_prelink")
add_custom_command(TARGET target_cmd POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "executing target_cmd_postbuild commands"
COMMAND ${CMAKE_COMMAND} -E echo "target_cmd_postbuild" > target_cmd_postbuild.txt
BYPRODUCTS target_cmd_postbuild.txt
COMMENT "CT: Processing target_cmd_postbuild")
add_custom_target(target_empty ALL
COMMENT "CT: Processing target_empty")
add_custom_command(TARGET target_empty PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "target_empty_prebuild" > target_empty_prebuild.txt
BYPRODUCTS target_empty_prebuild.txt
COMMENT "CT: Processing target_empty_prebuild")
add_custom_command(TARGET target_empty POST_BUILD
COMMAND ${CMAKE_COMMAND} -E echo "target_empty_postbuild" > target_empty_postbuild.txt
BYPRODUCTS target_empty_postbuild.txt
COMMENT "CT: Processing target_empty_postbuild")
add_dependencies(target_cmd target_empty)
add_custom_command(
OUTPUT out_of_order_dep.txt
COMMAND ${CMAKE_COMMAND} -E echo "out_of_order_dep" > out_of_order_dep.txt
COMMENT "CT: generate text file out_of_order_dep"
DEPENDS dependsA.txt
)
if(TEST_MISSING_TARGET_SRC)
set(SRC_FILE does_not_exist)
endif()
if(TEST_MISSING_TARGET_DEP)
set(DEP_FILE does_not_exist)
endif()
add_custom_target(target_update_files
DEPENDS genc_do_not_list.txt ${DEP_FILE}
SOURCES gena.txt genb.txt another_file.c ${SRC_FILE}
BYPRODUCTS junkit.txt
COMMAND ${CMAKE_COMMAND} -E copy another_file.c junkit.txt
COMMENT "CT: Processing target_update_files")
add_custom_command(
OUTPUT force_rebuild gena.txt genb.txt genc_do_not_list.txt
COMMAND ${CMAKE_COMMAND} -E copy dependsA.txt gena.txt
COMMAND ${CMAKE_COMMAND} -E echo "genb" > genb.txt
COMMAND ${CMAKE_COMMAND} -E echo "genc" > genc_do_not_list.txt
DEPENDS out_of_order_dep.txt dependsA.txt
COMMENT "CT: generate text files A, B, and C"
)
if(TEST_MISSING_DEP)
set(MISSING_DEP MISSING_DEP)
endif()
if(TEST_DEP_CYCLE)
set(DEP_CYCLE out_of_order_dep.txt)
endif()
add_custom_command(
OUTPUT dependsA.txt
COMMAND ${CMAKE_COMMAND} -E echo "dependsA" > dependsA.txt
DEPENDS ${MISSING_DEP} ${DEP_CYCLE} another_file.c
COMMENT "CT: generate text file dependsA"
)
add_custom_command(
OUTPUT another_file.c
COMMAND ${CMAKE_COMMAND} -E echo "//auto-gen file" > another_file.c
COMMENT "CT: generate C file another_file"
)
add_dependencies(target_update_files target_empty)
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
project(test C)
#set_property( GLOBAL PROPERTY GLOBAL_DEPENDS_DEBUG_MODE 1)
add_subdirectory(exec)
add_subdirectory(lib)
add_subdirectory(protolib)
add_dependencies(lib1 proto)
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
add_executable(exe1 exe1.c)
target_link_libraries(exe1 lib1)
target_include_directories(exe1 PRIVATE "${test_BINARY_DIR}")
if(CMAKE_C_COMPILER_ID STREQUAL "GHS")
target_link_options(exe1 PRIVATE "-non_shared")
endif()
#include "lib1.h"
#include "p.h"
int main(void)
{
return func1() + func2() + func3() + func1p() + func2p() + func3p() +
PROTO1 + PROTO2 + PROTO3;
}
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
add_library(lib1 STATIC
func1.c lib1.h
"${test_BINARY_DIR}/protolib/proto1.c"
"${test_BINARY_DIR}/protolib/proto1.h")
set_source_files_properties(
"${test_BINARY_DIR}/protolib/proto1.c"
"${test_BINARY_DIR}/protolib/proto1.h"
PROPERTIES GENERATED 1)
target_include_directories(lib1 PRIVATE "${test_BINARY_DIR}/protolib"
PUBLIC .)
add_custom_command( TARGET lib1 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy "${test_BINARY_DIR}/protolib/proto1.h" "${test_BINARY_DIR}/p.h"
COMMENT "Copy ${test_BINARY_DIR}/protolib/proto1.h ${test_BINARY_DIR}/p.h"
BYPRODUCTS "${test_BINARY_DIR}/p.h")
#include "lib1.h"
#include "proto1.h"
int func1(void)
{
return 1 + PROTO1;
}
int func2(void)
{
return 2 + PROTO2;
}
int func3(void)
{
return 3 + PROTO3;
}
extern int func1(void);
extern int func2(void);
extern int func3(void);
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
add_custom_target(proto ALL
DEPENDS proto1.c
proto1.h
SOURCES
${test_SOURCE_DIR}/protolib/proto1.c.in
${test_SOURCE_DIR}/protolib/proto1.h.in
COMMENT "Creating proto files")
add_custom_command(
OUTPUT proto1.c
COMMAND ${CMAKE_COMMAND} -E copy
${test_SOURCE_DIR}/protolib/proto1.c.in proto1.c
DEPENDS ${test_SOURCE_DIR}/protolib/proto1.c.in
COMMENT "generate proto C files"
)
add_custom_command(
OUTPUT proto1.h
COMMAND ${CMAKE_COMMAND} -E copy
${test_SOURCE_DIR}/protolib/proto1.h.in proto1.h
DEPENDS ${test_SOURCE_DIR}/protolib/proto1.h.in
COMMENT "generate proto H files"
)
#include "proto1.h"
int func1p(void)
{
return 1;
}
int func2p(void)
{
return 2;
}
int func3p(void)
{
return 3;
}
extern int func1p(void);
extern int func2p(void);
extern int func3p(void);
#define PROTO1 0x1
#define PROTO2 0x2
#define PROTO3 0x3
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
project(test C)
include(ExternalProject)
ExternalProject_Add(another_project
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/empty
BINARY_DIR empty_build
INSTALL_COMMAND ""
TEST_COMMAND ""
)
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
project(empty NONE)
message("EMPTY PROJECT")
add_executable(App Main.c)
target_include_directories(App PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../Lib)
target_link_libraries(App Lib)
target_compile_options(App PUBLIC "-non_shared")
add_library(Lib HelperFun.c HelperFun.h)
target_include_directories(Lib PUBLIC .)
......@@ -18,3 +18,4 @@ target_link_options(kernel PRIVATE -kernel)
# create monolith INTEGRITY application
add_executable(monolith test.int)
add_dependencies(monolith vas)
......@@ -13,7 +13,7 @@ endif()
if(RUN_TEST STREQUAL "SINGLE_EXEC")
add_executable(exe1 exe.c)
set(targets_to_install ${targets_to_install} exe1)
set(targets_to_install exe1)
endif()
if(RUN_TEST STREQUAL "SINGLE_EXEC_RENAMED")
......@@ -22,7 +22,7 @@ if(RUN_TEST STREQUAL "SINGLE_EXEC_RENAMED")
set_property(TARGET exe1 PROPERTY RUNTIME_OUTPUT_DIRECTORY ${name}_bin_$<CONFIG>)
set_property(TARGET exe1 PROPERTY OUTPUT_NAME ${name}_$<CONFIG>)
set_property(TARGET exe1 PROPERTY SUFFIX .bin)
set(targets_to_install ${targets_to_install} exe1)
set(targets_to_install exe1)
endif()
if(RUN_TEST STREQUAL "EXEC_AND_LIB")
......@@ -33,7 +33,7 @@ if(RUN_TEST STREQUAL "EXEC_AND_LIB")
add_executable(exe1 exe1.c)
target_link_libraries(exe1 lib1)
set(targets_to_install ${targets_to_install} exe1 lib1)
set(targets_to_install exe1 lib1)
endif()
install(TARGETS ${targets_to_install}
......
......@@ -5,8 +5,6 @@ cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
project(test C)
add_custom_target(testTarget ALL echo this is a test)
add_library(sharedLib SHARED file.c)
add_library(moduleLib MODULE file.c)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment