Skip to content
This repository was archived by the owner on Jul 14, 2022. It is now read-only.

Commit af2ac9b

Browse files
authored
Merge pull request #8 from Alpine-DAV/make_example
using with make
2 parents 0ec06ef + 1128f66 commit af2ac9b

File tree

7 files changed

+212
-35
lines changed

7 files changed

+212
-35
lines changed

azure-pipelines.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,16 @@ stages:
150150
./apcomp_example
151151
displayName: 'Test vs Install (using-with-cmake)'
152152
condition: succeeded()
153+
154+
- script: |
155+
###########################
156+
# using with make example
157+
###########################
158+
cat install/share/apcomp/apcomp_config.mk
159+
pwd
160+
ls -l
161+
cd install/examples/apcomp/using-with-make
162+
make
163+
./apcomp_example
164+
displayName: 'Test vs Install (using-with-make)'
165+
condition: succeeded()

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ if (NOT DEFINED APComp_INSTALL_BIN_DIR)
2828
set(APComp_INSTALL_BIN_DIR "bin")
2929
endif()
3030
if (NOT DEFINED APComp_INSTALL_SHARED_RESOURCES_DIR)
31-
set(APComp_INSTALL_SHARED_RESOURCES_DIR "share/vtkh")
31+
set(APComp_INSTALL_SHARED_RESOURCES_DIR "lib/")
3232
endif()
3333
if (NOT DEFINED APComp_INSTALL_CMAKE_MODULE_DIR)
3434
set(APComp_INSTALL_CMAKE_MODULE_DIR "${APComp_INSTALL_SHARED_RESOURCES_DIR}/cmake")

src/config/CMakeLists.txt

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -49,29 +49,23 @@
4949
# export everything for a cmake build to be able to import with find_package
5050
###############################################################################
5151

52-
if (NOT DEFINED APCOMP_INSTALL_INCLUDE_DIR)
53-
set(APCOMP_INSTALL_INCLUDE_DIR "include")
52+
set(APCOMP_CONFIG_MK_MPI_LINK_FLAGS "")
53+
if(MPI_FOUND)
54+
foreach(_lib ${MPI_C_LIBRARIES})
55+
set(APCOMP_CONFIG_MK_MPI_LINK_FLAGS "${APCOMP_CONFIG_MK_MPI_LINK_FLAGS} ${_lib}")
56+
endforeach()
57+
58+
foreach(_lib ${MPI_CXX_LIBRARIES})
59+
set(APCOMP_CONFIG_MK_MPI_LINK_FLAGS "${APCOMP_CONFIG_MK_MPI_LINK_FLAGS} ${_lib}")
60+
endforeach()
5461
endif()
5562

56-
if (NOT DEFINED APCOMP_INSTALL_CONFIG_DIR)
57-
set(APCOMP_INSTALL_CONFIG_DIR "lib")
58-
endif()
59-
60-
if (NOT DEFINED APCOMP_INSTALL_LIB_DIR)
61-
set(APCOMP_INSTALL_LIB_DIR "lib")
62-
endif()
63-
64-
if (NOT DEFINED APCOMP_INSTALL_BIN_DIR)
65-
set(APCOMP_INSTALL_BIN_DIR "bin")
66-
endif()
67-
68-
if (NOT DEFINED APCOMP_INSTALL_SHARED_RESOURCES_DIR)
69-
set(APCOMP_INSTALL_SHARED_RESOURCES_DIR "share/apcomp")
70-
endif()
63+
# generated the config.mk
64+
configure_file ("${CMAKE_CURRENT_SOURCE_DIR}/apcomp_config.mk.in"
65+
"${CMAKE_CURRENT_BINARY_DIR}/apcomp_config.mk")
7166

72-
if (NOT DEFINED APCOMP_INSTALL_CMAKE_MODULE_DIR)
73-
set(APCOMP_INSTALL_CMAKE_MODULE_DIR "${APCOMP_INSTALL_CONFIG_DIR}/cmake")
74-
endif()
67+
# install the config.mk
68+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/apcomp_config.mk" DESTINATION share/apcomp)
7569

7670
include(CMakePackageConfigHelpers)
7771

@@ -82,29 +76,23 @@ write_basic_package_version_file(
8276
COMPATIBILITY AnyNewerVersion
8377
)
8478

85-
8679
# write cmake package config file
8780
configure_package_config_file(
8881
APCompConfig.cmake.in
8982
${CMAKE_CURRENT_BINARY_DIR}/APCompConfig.cmake
90-
INSTALL_DESTINATION ${APCOMP_INSTALL_CONFIG_DIR}
83+
INSTALL_DESTINATION ${APComp_INSTALL_CONFIG_DIR}
9184
PATH_VARS
92-
APCOMP_INSTALL_INCLUDE_DIR
93-
APCOMP_INSTALL_LIB_DIR
94-
APCOMP_INSTALL_BIN_DIR
95-
APCOMP_INSTALL_SHARED_RESOURCES_DIR
96-
APCOMP_INSTALL_CMAKE_MODULE_DIR
85+
APComp_INSTALL_INCLUDE_DIR
86+
APComp_INSTALL_LIB_DIR
87+
APComp_INSTALL_BIN_DIR
88+
APComp_INSTALL_SHARED_RESOURCES_DIR
89+
APComp_INSTALL_CMAKE_MODULE_DIR
9790
)
9891

9992

10093
# install everything needed
10194
install(FILES
10295
${CMAKE_CURRENT_BINARY_DIR}/APCompConfig.cmake
10396
${CMAKE_CURRENT_BINARY_DIR}/APCompConfigVersion.cmake
104-
DESTINATION ${APCOMP_INSTALL_CMAKE_MODULE_DIR})
105-
106-
107-
108-
109-
97+
DESTINATION ${APComp_INSTALL_CMAKE_MODULE_DIR})
11098

src/config/apcomp_config.mk.in

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
###############################################################################
2+
# Copyright (c) 2015-2018, Lawrence Livermore National Security, LLC.
3+
#
4+
# Produced at the Lawrence Livermore National Laboratory
5+
#
6+
# LLNL-CODE-716457
7+
#
8+
# All rights reserved.
9+
#
10+
# Please also read apcomp/LICENSE
11+
#
12+
# Redistribution and use in source and binary forms, with or without
13+
# modification, are permitted provided that the following conditions are met:
14+
#
15+
# * Redistributions of source code must retain the above copyright notice,
16+
# this list of conditions and the disclaimer below.
17+
#
18+
# * Redistributions in binary form must reproduce the above copyright notice,
19+
# this list of conditions and the disclaimer (as noted below) in the
20+
# documentation and/or other materials provided with the distribution.
21+
#
22+
# * Neither the name of the LLNS/LLNL nor the names of its contributors may
23+
# be used to endorse or promote products derived from this software without
24+
# specific prior written permission.
25+
#
26+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29+
# ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
30+
# LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
31+
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33+
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34+
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
35+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
36+
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37+
# POSSIBILITY OF SUCH DAMAGE.
38+
#
39+
###############################################################################
40+
41+
###############################################################################
42+
# file: apcomp_config.mk
43+
###############################################################################
44+
#
45+
# A CMake-generated Make include file Defines the following Make variables:
46+
#
47+
######
48+
# APCOMP_INCLUDE_FLAGS
49+
# APCOMP_LIB_FLAGS
50+
# APCOMP_MPI_LIB_FLAGS
51+
######
52+
#
53+
# For us in another Makefile build system
54+
############################################################################
55+
56+
57+
APCOMP_DIR = @CMAKE_INSTALL_PREFIX@
58+
59+
APCOMP_OPENMP_LINK_FLAGS = @OpenMP_CXX_FLAGS@
60+
61+
APCOMP_MPI_LIBS =@APCOMP_CONFIG_MK_MPI_LINK_FLAGS@
62+
63+
# setup rpath helper
64+
APCOMP_LINK_RPATH = -Wl,-rpath,$(APCOMP_DIR)/lib
65+
66+
#######################
67+
# APComp Include Flags
68+
#######################
69+
APCOMP_INCLUDE_FLAGS = -I $(APCOMP_DIR)/include/
70+
71+
72+
####################
73+
# APComp Lib Flags
74+
####################
75+
# if using apcomp without mpi
76+
APCOMP_LIB_FLAGS = -L $(APCOMP_DIR)/lib \
77+
-lapcomp \
78+
$(APCOMP_OPENMP_LINK_FLAGS)
79+
80+
# if using apcomp with mpi
81+
APCOMP_MPI_LIB_FLAGS = -L $(APCOMP_DIR)/lib \
82+
-lapcomp_mpi \
83+
$(APCOMP_MPI_LIBS) $(ASCENT_OPENMP_LINK_FLAGS)

src/examples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
install(DIRECTORY using-with-cmake
1+
install(DIRECTORY using-with-cmake using-with-make
22
DESTINATION examples/apcomp)
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
###############################################################################
2+
# Copyright (c) 2015-2019, Lawrence Livermore National Security, LLC.
3+
#
4+
# Produced at the Lawrence Livermore National Laboratory
5+
#
6+
# LLNL-CODE-716457
7+
#
8+
# All rights reserved.
9+
#
10+
# Please also read apcomp/LICENSE
11+
#
12+
# Redistribution and use in source and binary forms, with or without
13+
# modification, are permitted provided that the following conditions are met:
14+
#
15+
# * Redistributions of source code must retain the above copyright notice,
16+
# this list of conditions and the disclaimer below.
17+
#
18+
# * Redistributions in binary form must reproduce the above copyright notice,
19+
# this list of conditions and the disclaimer (as noted below) in the
20+
# documentation and/or other materials provided with the distribution.
21+
#
22+
# * Neither the name of the LLNS/LLNL nor the names of its contributors may
23+
# be used to endorse or promote products derived from this software without
24+
# specific prior written permission.
25+
#
26+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
27+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29+
# ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
30+
# LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
31+
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33+
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34+
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
35+
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
36+
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37+
# POSSIBILITY OF SUCH DAMAGE.
38+
#
39+
###############################################################################
40+
41+
###############################################################################
42+
#
43+
# Example that shows how to use an installed instance of APComp in Makefile
44+
# based build system.
45+
#
46+
# To build:
47+
# env APCOMP_DIR={apcomp install path} make
48+
# ./apcomp_example
49+
#
50+
# From within an apcomp install:
51+
# make
52+
# ./example
53+
#
54+
# Which corresponds to:
55+
#
56+
# make APCOMP_DIR=../../../
57+
# ./example
58+
#
59+
###############################################################################
60+
61+
APCOMP_DIR ?= ../../..
62+
63+
# See $(APCOMP_DIR)/share/apcomp/apcomp_config.mk for detailed linking info
64+
include $(APCOMP_DIR)/share/apcomp/apcomp_config.mk
65+
66+
67+
INC_FLAGS = $(APCOMP_INCLUDE_FLAGS)
68+
LNK_FLAGS = $(APCOMP_LINK_RPATH) $(APCOMP_LIB_FLAGS)
69+
70+
main:
71+
$(CXX) $(INC_FLAGS) apcomp_example.cpp $(LNK_FLAGS) -o apcomp_example
72+
73+
74+
clean:
75+
rm -f apcomp_example
76+
77+
78+
# TODO: Add mpi example
79+
80+
81+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <apcomp/apcomp.hpp>
2+
3+
#include <iostream>
4+
5+
using namespace std;
6+
7+
int main(void)
8+
{
9+
std::cout<<apcomp::about();
10+
return 0;
11+
}
12+

0 commit comments

Comments
 (0)