Merge some GenerateExportHeader subtests.

This commit is contained in:
Stephen Kelly 2013-12-15 11:14:23 +01:00
parent 4017db13aa
commit 2410b912fe
15 changed files with 28 additions and 143 deletions

View File

@ -57,7 +57,7 @@ endif()
include(GenerateExportHeader)
add_subdirectory(visibility_preset)
add_subdirectory(lib_shared_and_static)
add_compiler_export_flags()
@ -79,11 +79,8 @@ endmacro()
macro_add_test_library(libshared)
macro_add_test_library(libstatic)
add_subdirectory(lib_shared_and_static)
add_subdirectory(override_symbol)
add_subdirectory(nodeprecated)
add_subdirectory(prefix)
if(NOT BORLAND)
add_subdirectory(c_identifier)
endif()

View File

@ -5,7 +5,15 @@ project(lib_shared_and_static)
include(GenerateExportHeader)
add_compiler_export_flags()
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
if (CMAKE_CXX_FLAGS MATCHES "-fvisibility=hidden")
message(SEND_ERROR "Do not use add_compiler_export_flags before adding this directory")
endif()
if (CMAKE_CXX_FLAGS MATCHES "-fvisibility-inlines-hidden")
message(SEND_ERROR "Do not use add_compiler_export_flags before adding this directory")
endif()
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@ -14,9 +22,13 @@ set(lib_SRCS
)
add_library(shared_variant SHARED ${lib_SRCS})
set_target_properties(shared_variant PROPERTIES DEFINE_SYMBOL SHARED_VARIANT_MAKEDLL)
add_library(static_variant ${lib_SRCS})
generate_export_header(shared_variant BASE_NAME libshared_and_static)
generate_export_header(shared_variant
BASE_NAME libshared_and_static
PREFIX_NAME MYPREFIX_
)
set_target_properties(static_variant PROPERTIES COMPILE_FLAGS -DLIBSHARED_AND_STATIC_STATIC_DEFINE)

View File

@ -4,51 +4,51 @@
#include "libshared_and_static_export.h"
class LIBSHARED_AND_STATIC_EXPORT LibsharedAndStatic {
class MYPREFIX_LIBSHARED_AND_STATIC_EXPORT LibsharedAndStatic {
public:
int libshared_and_static() const;
int libshared_and_static_exported() const;
int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const;
int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const;
int libshared_and_static_not_exported() const;
int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const;
int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const;
};
class LibsharedAndStaticNotExported {
public:
int libshared_and_static() const;
int LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const;
int MYPREFIX_LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const;
int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const;
int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const;
int libshared_and_static_not_exported() const;
int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const;
int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const;
};
class LIBSHARED_AND_STATIC_NO_EXPORT LibsharedAndStaticExcluded {
class MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT LibsharedAndStaticExcluded {
public:
int libshared_and_static() const;
int LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const;
int MYPREFIX_LIBSHARED_AND_STATIC_EXPORT libshared_and_static_exported() const;
int LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const;
int MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED libshared_and_static_deprecated() const;
int libshared_and_static_not_exported() const;
int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const;
int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded() const;
};
LIBSHARED_AND_STATIC_EXPORT int libshared_and_static_exported();
MYPREFIX_LIBSHARED_AND_STATIC_EXPORT int libshared_and_static_exported();
LIBSHARED_AND_STATIC_DEPRECATED_EXPORT int libshared_and_static_deprecated();
MYPREFIX_LIBSHARED_AND_STATIC_DEPRECATED_EXPORT int libshared_and_static_deprecated();
int libshared_and_static_not_exported();
int LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded();
int MYPREFIX_LIBSHARED_AND_STATIC_NO_EXPORT libshared_and_static_excluded();
#endif

View File

@ -1,11 +0,0 @@
project(override_symbol)
add_library(somelib SHARED someclass.cpp)
set_target_properties(somelib PROPERTIES DEFINE_SYMBOL SOMELIB_MAKEDLL)
generate_export_header(somelib)
add_executable(consumer main.cpp)
target_link_libraries(consumer somelib)

View File

@ -1,9 +0,0 @@
#include "someclass.h"
int main(int, char**)
{
SomeClass sc;
sc.someMethod();
return 0;
}

View File

@ -1,7 +0,0 @@
#include "someclass.h"
void SomeClass::someMethod() const
{
}

View File

@ -1,8 +0,0 @@
#include "somelib_export.h"
class SOMELIB_EXPORT SomeClass
{
public:
void someMethod() const;
};

View File

@ -1,15 +0,0 @@
project(use_prefix)
set(use_prefix_lib_SRCS
useprefixclass.cpp
)
add_library(use_prefix_lib SHARED useprefixclass.cpp)
generate_export_header(use_prefix_lib
PREFIX_NAME MYPREFIX_
)
add_executable(use_prefix main.cpp)
target_link_libraries(use_prefix use_prefix_lib)

View File

@ -1,8 +0,0 @@
#include "useprefixclass.h"
int main(int argc, char **argv)
{
UsePrefixClass upc;
return upc.someMethod();
}

View File

@ -1,7 +0,0 @@
#include "useprefixclass.h"
int UsePrefixClass::someMethod() const
{
return 0;
}

View File

@ -1,13 +0,0 @@
#ifndef USEPREFIXCLASS_H
#define USEPREFIXCLASS_H
#include "use_prefix_lib_export.h"
class MYPREFIX_USE_PREFIX_LIB_EXPORT UsePrefixClass
{
public:
int someMethod() const;
};
#endif

View File

@ -1,17 +0,0 @@
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
if (CMAKE_CXX_FLAGS MATCHES "-fvisibility=hidden")
message(SEND_ERROR "Do not use add_compiler_export_flags before adding this directory")
endif()
if (CMAKE_CXX_FLAGS MATCHES "-fvisibility-inlines-hidden")
message(SEND_ERROR "Do not use add_compiler_export_flags before adding this directory")
endif()
add_library(visibility_preset SHARED visibility_preset.cpp)
generate_export_header(visibility_preset)
add_executable(visibility_preset_exe main.cpp)
target_link_libraries(visibility_preset_exe visibility_preset)

View File

@ -1,9 +0,0 @@
#include "visibility_preset.h"
int main()
{
VisibilityPreset vp;
vp.someMethod();
return 0;
}

View File

@ -1,7 +0,0 @@
#include "visibility_preset.h"
void VisibilityPreset::someMethod()
{
}

View File

@ -1,13 +0,0 @@
#ifndef VISIBILITY_PRESET_H
#define VISIBILITY_PRESET_H
#include "visibility_preset_export.h"
class VISIBILITY_PRESET_EXPORT VisibilityPreset
{
public:
void someMethod();
};
#endif