~ubuntu-branches/ubuntu/quantal/cmake/quantal

« back to all changes in this revision

Viewing changes to Tests/ObjectLibrary/CMakeLists.txt

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2012-04-30 12:14:32 UTC
  • mfrom: (3.1.30 sid)
  • Revision ID: package-import@ubuntu.com-20120430121432-rqh2fjl3zcblehh5
Tags: 2.8.8-2ubuntu1
* Merge from Debian unstable, remaining changes:
  - Add xfail_compiler_flag.diff: Mark compiler flag tests as expected
    failures.
  - Add ubuntu_qt_import_dir_variable.diff: define QT_IMPORTS_DIR even
    when that dir does not exist.
* Remove increase_ctest_test_timeout.diff, merged upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
cmake_minimum_required(VERSION 2.8)
 
2
project(ObjectLibrary C)
 
3
 
 
4
add_subdirectory(A)
 
5
add_subdirectory(B)
 
6
 
 
7
add_library(Cstatic STATIC c.c $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:B>)
 
8
add_executable(UseCstatic main.c)
 
9
target_link_libraries(UseCstatic Cstatic)
 
10
 
 
11
add_library(Cshared SHARED c.c $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:Bexport>)
 
12
add_executable(UseCshared main.c)
 
13
set_property(TARGET UseCshared PROPERTY COMPILE_DEFINITIONS SHARED_C)
 
14
target_link_libraries(UseCshared Cshared)
 
15
 
 
16
add_executable(UseCinternal main.c c.c $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:B>)
 
17
 
 
18
if("${CMAKE_GENERATOR}" MATCHES "^Visual Studio (6|7|7 .NET 2003)$")
 
19
  # VS 6 and 7 generators do not add objects as sources so we need a
 
20
  # dummy object to convince the IDE to build the targets below.
 
21
  set(dummy dummy.obj) # In MinGW: gcc -c dummy.c -o dummy.obj
 
22
elseif("${CMAKE_GENERATOR}" MATCHES "Xcode")
 
23
  # Xcode does not seem to support targets without sources.
 
24
  set(dummy dummy.c)
 
25
endif()
 
26
 
 
27
# Test static library without its own sources.
 
28
add_library(ABstatic STATIC ${dummy} $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:B>)
 
29
add_executable(UseABstatic mainAB.c)
 
30
target_link_libraries(UseABstatic ABstatic)
 
31
 
 
32
# Test module definition file to export object library symbols in the test
 
33
# below if the platform needs and supports it.
 
34
set(ABshared_SRCS $<TARGET_OBJECTS:A>)
 
35
if(CMAKE_LINK_DEF_FILE_FLAG OR NOT WIN32)
 
36
  list(APPEND ABshared_SRCS $<TARGET_OBJECTS:B> AB.def)
 
37
else()
 
38
  set(NO_A NO_A)
 
39
  list(APPEND ABshared_SRCS $<TARGET_OBJECTS:Bexport>)
 
40
endif()
 
41
 
 
42
# Test shared library without its own sources.
 
43
add_library(ABshared SHARED ${dummy} ${ABshared_SRCS})
 
44
add_executable(UseABshared mainAB.c)
 
45
set_property(TARGET UseABshared PROPERTY COMPILE_DEFINITIONS SHARED_B ${NO_A})
 
46
target_link_libraries(UseABshared ABshared)
 
47
 
 
48
# Test executable without its own sources.
 
49
add_library(ABmain OBJECT mainAB.c)
 
50
add_executable(UseABinternal ${dummy}
 
51
  $<TARGET_OBJECTS:ABmain> $<TARGET_OBJECTS:A> $<TARGET_OBJECTS:B>
 
52
  )