Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,25 @@ project(microprofile)

option(MICROPROFILE_USE_CONFIG_FILE "Use user provided configuration in microprofile.config.h file." OFF)

set(MICROPROFILE_EXPORT_FILENAME microprofile.export.h)
set(MICROPROFILE_CONFIG_HEADER ${PROJECT_SOURCE_DIR}/microprofile.config.h)
set(MICROPROFILE_PUBLIC_HEADERS
${PROJECT_SOURCE_DIR}/microprofile.h
${CMAKE_CURRENT_BINARY_DIR}/${MICROPROFILE_EXPORT_FILENAME}
)
set(MICROPROFILE_PUBLIC_HEADERS ${PROJECT_SOURCE_DIR}/microprofile.h)

set(THREADS_PREFER_PTHREAD_FLAG ON)

add_library(${PROJECT_NAME} microprofile.cpp)

include(GenerateExportHeader)
generate_export_header(${PROJECT_NAME}
EXPORT_MACRO_NAME MICROPROFILE_API
EXPORT_FILE_NAME ${MICROPROFILE_EXPORT_FILENAME}
)
add_library(${PROJECT_NAME} SHARED microprofile.cpp)

target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)

target_compile_definitions(${PROJECT_NAME} PUBLIC MICROPROFILE_EXPORT)
target_compile_definitions(${PROJECT_NAME}
PUBLIC
MICROPROFILE_SHARED
PRIVATE
MICROPROFILE_EXPORT_SYMBOLS
)

if (MICROPROFILE_USE_CONFIG_FILE)
target_compile_definitions(${PROJECT_NAME} PUBLIC MICROPROFILE_USE_CONFIG)
Expand Down
42 changes: 26 additions & 16 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,21 @@ project(
'cpp_std=c++11'
],
license: 'MIT',
meson_version: '>=0.46.0'
meson_version: '>=0.46.0',
version: '5.0'
)

# Dependencies

deps = [dependency('threads')]

extra_args = []
private_args = []

if get_option('default_library') == 'shared'
private_args += '-DMICROPROFILE_EXPORT_SYMBOLS'
extra_args += '-DMICROPROFILE_SHARED'
endif

compiler = meson.get_compiler('cpp')

Expand Down Expand Up @@ -79,33 +86,36 @@ include_dir = include_directories('.')

if get_option('microprofile_use_config')
extra_args += '-DMICROPROFILE_USE_CONFIG'
install_headers('microprofile.config.h')
if get_option('install')
install_headers('microprofile.config.h')
endif
endif

# Main build target

libmicroprofile = library(
'microprofile',
'microprofile.cpp',
cpp_args: extra_args,
cpp_args: extra_args + private_args,
dependencies: deps,
include_directories: include_dir,
install: true
install: get_option('install')
)

# Headers and pkg-config installation

install_headers(
'microprofile.h',
'microprofile_html.h'
)

import('pkgconfig').generate(
libmicroprofile,
description: 'microprofile is an embeddable profiler',
extra_cflags: extra_args,
url: 'https://github.com/jonasmr/microprofile'
)
if get_option('install')
install_headers(
'microprofile.h',
'microprofile_html.h'
)

import('pkgconfig').generate(
libmicroprofile,
description: 'microprofile is an embeddable profiler',
extra_cflags: extra_args,
url: 'https://github.com/jonasmr/microprofile'
)
endif

# Declaring the dependency so that microprofile can be used as a subproject

Expand Down
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
option('microprofile_use_config', type: 'boolean', value: false, description: 'Use custom microprofile.config.h')
option('install', type: 'boolean', value: false, description: 'Install microprofile?')
40 changes: 34 additions & 6 deletions microprofile.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,12 +463,40 @@ typedef uint16_t MicroProfileGroupId;

#include <stdint.h>

#ifdef MICROPROFILE_EXPORT
#include "microprofile.export.h"
#else
#ifndef MICROPROFILE_API
#define MICROPROFILE_API
#endif
#ifndef MICROPROFILE_EXPORT
# if defined _WIN32 || defined __CYGWIN__
# ifdef __GNUC__
# define MICROPROFILE_EXPORT __attribute__( ( dllexport ) )
# else // __GNUC__
# define MICROPROFILE_EXPORT __declspec( dllexport )
# endif // __GNUC__
# elif defined __GNUC__ && __GNUC__ >= 4
# define MICROPROFILE_EXPORT __attribute__( ( visibility( "default" ) ) )
# else
# define MICROPROFILE_EXPORT
# endif
#endif // MICROPROFILE_EXPORT

#ifndef MICROPROFILE_IMPORT
# if defined _WIN32 || defined __CYGWIN__
# ifdef __GNUC__
# define MICROPROFILE_IMPORT __attribute__( ( dllimport ) )
# else // __GNUC__
# define MICROPROFILE_IMPORT __declspec( dllimport )
# endif // __GNUC__
# else
# define MICROPROFILE_IMPORT
# endif
#endif // MICROPROFILE_IMPORT

#if defined( MICROPROFILE_SHARED )
# if defined MICROPROFILE_EXPORT_SYMBOLS
# define MICROPROFILE_API MICROPROFILE_EXPORT
# else
# define MICROPROFILE_API MICROPROFILE_IMPORT
# endif
#else // MICROPROFILE_SHARED is not defined, building a static library
# define MICROPROFILE_API
#endif

#ifdef MICROPROFILE_PS4
Expand Down