mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-26 08:08:24 -05:00
ENH: check in initial conv library stuff
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
project(foo)
|
||||
|
||||
# create a source list
|
||||
set(foo_sources foo.cxx bar.c sub1/car.cxx)
|
||||
# create a library foo from the sources
|
||||
add_library(foo ${foo_sources})
|
||||
# get the object files from the target
|
||||
get_target_property(OBJECT_FILES foo OBJECT_FILES)
|
||||
message("${OBJECT_FILES}")
|
||||
# set the object files as generated
|
||||
set_source_files_properties(${OBJECT_FILES} PROPERTIES GENERATED true)
|
||||
# create a library bar that contains the object files from foo
|
||||
add_library(bar ${OBJECT_FILES})
|
||||
# set the linker language since bar only has .obj
|
||||
set_target_properties(bar PROPERTIES LINKER_LANGUAGE CXX)
|
||||
# make sure foo is built before bar
|
||||
add_dependencies(bar foo)
|
||||
add_executable(bartest bartest.cxx)
|
||||
target_link_libraries(bartest bar)
|
||||
@@ -0,0 +1,4 @@
|
||||
int bar()
|
||||
{
|
||||
return 20;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
extern "C" int bar();
|
||||
int foo();
|
||||
int car();
|
||||
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
{
|
||||
if(foo() == 10)
|
||||
{
|
||||
printf("foo is 10!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("foo is not 10 error!\n");
|
||||
return -1;
|
||||
}
|
||||
if(bar() == 20)
|
||||
{
|
||||
printf("bar is 20!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("bar is not 20 error!\n");
|
||||
return -1;
|
||||
}
|
||||
if(car() == 30)
|
||||
{
|
||||
printf("bar is 30!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("bar is not 30 error!\n");
|
||||
return -1;
|
||||
}
|
||||
printf("Test past\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
int foo()
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
int car()
|
||||
{
|
||||
return 30;
|
||||
}
|
||||
Reference in New Issue
Block a user