Skip to content

Commit

Permalink
Merge branch 'fix_crossplatform_build'
Browse files Browse the repository at this point in the history
Previously a custom tool for installing the headers was built. This is
not compatible with cross-platform build so the tool was replaced with
a cmake script.
  • Loading branch information
mmahnic committed Jan 1, 2020
2 parents 6bb5b04 + b9a4d46 commit 43a044b
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 126 deletions.
7 changes: 3 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required( VERSION 3.1 )

project( Argumentum VERSION 0.2.0 )
project( Argumentum VERSION 0.2.2 )

option( BUILD_STATIC_LIBS "Build static libraries" ON )
option( ARGUMENTUM_BUILD_EXAMPLES "Build examples" OFF )
Expand All @@ -17,13 +17,12 @@ set( CMAKE_DEBUG_POSTFIX d )
include( GNUInstallDirs )

# The name of the published static library target.
set( ARGUMENTUM_STATIC_NAME argumentum-s )
set( ARGUMENTUM_STATIC_NAME argumentum )

# The name of the internal static library target used for instutil, tests, examples.
# The name of the internal static library target used for tests, examples.
set( ARGUMENTUM_INTERNAL_NAME argumentum-si )

add_subdirectory( src )
add_subdirectory( util )
add_subdirectory( include )

include( cmake/InstallConfig.cmake )
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![Build Status](https://travis-ci.com/mmahnic/cpp-argparse.svg?branch=master)](https://travis-ci.com/mmahnic/cpp-argparse)
[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/mmahnic/cpp-argparse.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/mmahnic/cpp-argparse/context:cpp)
[![Build Status](https://travis-ci.com/mmahnic/argumentum.svg?branch=master)](https://travis-ci.com/mmahnic/argumentum)
[![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/mmahnic/argumentum.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/mmahnic/argumentum/context:cpp)

# Argumentum / Argparse

Expand Down
4 changes: 1 addition & 3 deletions doc/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@ sudo make install

```
find_package( Argumentum CONFIG REQUIRED )
set( Argumentum_LIBRARIES Argumentum::argumentum-s )
set( CMAKE_CXX_STANDARD 17 )
add_executable( example
main.cpp
)
target_link_libraries( example
${Argumentum_LIBRARIES}
Argumentum::argumentum
)
```

Expand Down
28 changes: 18 additions & 10 deletions include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@

file( GLOB copied_headers "${CMAKE_SOURCE_DIR}/src/*.h" )

add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/fake_create_headers.cpp
DEPENDS instutil argumentum/argparse.h
COMMENT "Preparing library headers for publishing"
OUTPUT
${CMAKE_CURRENT_BINARY_DIR}/fake_create_headers.cpp
${CMAKE_CURRENT_BINARY_DIR}/argumentum/argparse.h
DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/argumentum/argparse.h
${copied_headers}

COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/argumentum
COMMENT "Preparing library headers for publishing"

COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/argumentum/inc
COMMAND ${CMAKE_COMMAND}
-E copy
"${CMAKE_SOURCE_DIR}/util/faketarget.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/fake_create_headers.cpp"

COMMAND instutil fake-target fake_create_headers.cpp
COMMAND instutil header
${CMAKE_CURRENT_SOURCE_DIR}/argumentum/argparse.h
${CMAKE_CURRENT_BINARY_DIR}/argumentum/argparse.h
COMMAND ${CMAKE_COMMAND}
-D TOP_SOURCE_DIR="${CMAKE_SOURCE_DIR}"
-D P_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
-D P_BINARY_DIR="${CMAKE_CURRENT_BINARY_DIR}"
-P "${CMAKE_CURRENT_SOURCE_DIR}/prepare-headers.cmake"
)

add_executable( fake_create_headers
Expand Down
18 changes: 18 additions & 0 deletions include/prepare-headers.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Run with cmake -P
# Parameters (-D): TOP_SOURCE_DIR, P_BINARY_DIR, P_SOURCE_DIR

file( MAKE_DIRECTORY ${P_BINARY_DIR}/argumentum )

file( COPY ${TOP_SOURCE_DIR}/src/
DESTINATION ${P_BINARY_DIR}/argumentum/inc/
FILES_MATCHING PATTERN "*.h"
)

file( READ ${P_SOURCE_DIR}/argumentum/argparse.h
main_header )

string( REPLACE "../../src/" "inc/"
main_header "${main_header}" )

file( WRITE ${P_BINARY_DIR}/argumentum/argparse.h
"${main_header}" )
21 changes: 0 additions & 21 deletions util/CMakeLists.txt

This file was deleted.

4 changes: 4 additions & 0 deletions util/faketarget.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
int main()
{
return 0;
}
86 changes: 0 additions & 86 deletions util/instutil.cpp

This file was deleted.

0 comments on commit 43a044b

Please sign in to comment.