Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
b9cf04d
add function get_data_file_path()
gdamiand Jan 19, 2021
afa51d7
Set CGAL_DATA_DIR in cmake (TODO: two default directories depending i…
gdamiand Jan 19, 2021
1d88621
One example of use of get_data_file_path
gdamiand Jan 19, 2021
dbdac7a
whitespaces
gdamiand Jan 19, 2021
a00a539
Use CGAL_DATA_DIR only if it is defined
gdamiand Jan 19, 2021
8296ba7
Remove cmp file for theta_io example in Cone_spanners_2 package.
gdamiand Jan 20, 2021
ea10502
Create directories for data (for now with one empty file toremove later)
gdamiand Jan 20, 2021
9e9c183
Simplify function get_data_file_path (thanks @lrineau)
gdamiand Jan 20, 2021
93017e8
remove get_ prefix
sloriot Jan 21, 2021
5e4170b
remove placeholders
sloriot Feb 4, 2021
8094be4
update script generating test scripts to account for CGAL_DATA_DIR
sloriot Feb 4, 2021
6197135
set CGAL_DATA_DIR for ctest and cmd files
sloriot Feb 4, 2021
7688066
update release creation script
sloriot Feb 4, 2021
1e60a14
update default
sloriot Feb 4, 2021
a7ed934
add missing quotes
sloriot Feb 4, 2021
71c41da
also remove data/test for public release
sloriot Feb 4, 2021
c8d55e9
copy data...
sloriot Feb 4, 2021
6e06ef1
global data path is used when building all tests/examples/demos
sloriot Feb 4, 2021
fab5d07
add missing export
sloriot Feb 4, 2021
422e0c3
use string instead of char*
sloriot Feb 5, 2021
4c93263
fix wrong path
sloriot Feb 9, 2021
3cefeeb
set CGAL_DATA_DIR in CGALconfig.cmake
sloriot Feb 11, 2021
6e3828f
add in .in files
sloriot Feb 12, 2021
913d6a6
Update Installation/cmake/modules/CGALConfig_binary.cmake.in
sloriot Feb 12, 2021
3557c61
Use CGAL_SOURCE_DIR instead of CMAKE_SOURCE_DIR
gdamiand Mar 16, 2021
63b1916
Add one example and one test in this pr to test the use of CGAL::data…
gdamiand Mar 16, 2021
0939b0d
Use target_compile_definitions instead of add_definitions
gdamiand Mar 16, 2021
d140e5b
Add CGAL::Data target; link exe with this target in the create_single…
gdamiand Mar 19, 2021
751fb38
Merge branch 'master' into CGAL_data-gdamiand
gdamiand Mar 19, 2021
1c50254
Update one test in Point_set_processing_3 that uses a .cmd allowing t…
gdamiand Mar 19, 2021
d87f7d7
use CGAL_ROOT
sloriot Apr 8, 2021
75be03f
update autotest
sloriot Apr 8, 2021
878aef3
simplify
sloriot Apr 8, 2021
3aa8506
Merge branch 'master' into CGAL_data-gdamiand
gdamiand Apr 30, 2021
5e4372f
Avoid /cygdrive/c/ in the CGAL_DIR_PATH, it doesn't work when compile…
maxGimeno May 4, 2021
8593825
Add special code for windows to replace the use of getenv
gdamiand May 4, 2021
1d640c9
Merge branch 'CGAL_data-gdamiand' of github.com:gdamiand/cgal into CG…
gdamiand May 4, 2021
d7f56bb
Fix for MSVC
maxGimeno May 4, 2021
f6e27d4
fix for windows
gdamiand May 4, 2021
2a6437f
Merge branch 'CGAL_data-gdamiand' of github.com:gdamiand/cgal into CG…
gdamiand May 4, 2021
9ae15ac
trailing
gdamiand May 4, 2021
386900e
Do not use envsubst
gdamiand May 19, 2021
9571a88
Add backslashs
gdamiand May 27, 2021
f153a1e
Merge remote-tracking branch 'cgal/master' into HEAD
sloriot Jul 22, 2021
1f4feaf
fix path
sloriot Jul 27, 2021
78b0b2a
add target def in generated files for install
sloriot Sep 16, 2021
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
2 changes: 1 addition & 1 deletion AABB_tree/examples/AABB_tree/AABB_ray_shooting_example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct Skip

int main(int argc, char* argv[])
{
const char* filename = (argc > 1) ? argv[1] : "data/tetrahedron.off";
const std::string filename = (argc > 1) ? argv[1] : CGAL::data_file_path("meshes/tetrahedron.off");

Mesh mesh;
if(!CGAL::IO::read_polygon_mesh(filename, mesh))
Expand Down
3 changes: 1 addition & 2 deletions AABB_tree/test/AABB_tree/aabb_correctness_triangle_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ int test()
// load polyhedron
typedef CGAL::Polyhedron_3<K> Polyhedron;
Polyhedron polyhedron;
std::ifstream ifs("./data/tetrahedron.off");
std::ifstream ifs(CGAL::data_file_path("meshes/tetrahedron.off"));
ifs >> polyhedron;

// construct tree from facets
Expand Down Expand Up @@ -129,4 +129,3 @@ int main()
/* Local Variables: */
/* tab-width: 2 */
/* End: */

1 change: 0 additions & 1 deletion Cone_spanners_2/examples/Cone_spanners_2/theta_io.cmd

This file was deleted.

27 changes: 19 additions & 8 deletions Cone_spanners_2/examples/Cone_spanners_2/theta_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,37 @@ typedef boost::adjacency_list<boost::listS,

int main(int argc, char ** argv)
{
if (argc < 3) {
unsigned int k=4; // By default, no. of cones==4
std::string filename="data/n9.cin"; // file used by default

if (argc > 1 &&
(!strcmp(argv[1],"-h") || !strcmp(argv[1],"--help") || !strcmp(argv[1],"-?")))
{
std::cout << "Usage: " << argv[0] << " <no. of cones> <input filename> [<direction-x> <direction-y>]" << std::endl;
return 1;
}

unsigned int k = atoi(argv[1]);
if (k<2) {
std::cout << "The number of cones should be larger than 1!" << std::endl;
return 1;
if (argc > 1)
{
k = atoi(argv[1]);
if (k<2) {
std::cout << "The number of cones should be larger than 1!" << std::endl;
return 1;
}
}

if (argc > 2)
{ filename=std::string(argv[2]); }

// open the file containing the vertex list
std::ifstream inf(argv[2]);
std::ifstream inf(filename);
if (!inf) {
std::cout << "Cannot open file " << argv[2] << "!" << std::endl;
std::cout << "Cannot open file " << filename << "!" << std::endl;
return 1;
}

Direction_2 initial_direction;
if (argc == 3)
if (argc == 1 || argc == 3)
initial_direction = Direction_2(1, 0); // default initial_direction
else if (argc == 5)
initial_direction = Direction_2(atof(argv[3]), atof(argv[4]));
Expand Down
11 changes: 11 additions & 0 deletions Data/data/meshes/tetrahedron.off
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
OFF
4 4 0
0.0 0.0 0.0
1.0 0.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0
3 0 1 2
3 0 3 1
3 0 2 3
3 1 3 2

4 changes: 2 additions & 2 deletions Installation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ include(GNUInstallDirs)
#
#--------------------------------------------------------------------------------------------------

message("== Setting paths ==")

if(CGAL_BRANCH_BUILD)

message(
Expand Down Expand Up @@ -857,6 +855,8 @@ if(NOT RUNNING_CGAL_AUTO_TEST)
endif()
endif()

message("== Setting paths ==")

#--------------------------------------------------------------------------------------------------
#
# -= CPack =-
Expand Down
11 changes: 11 additions & 0 deletions Installation/cmake/modules/CGALConfig_binary.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,15 @@ if( CGAL_DEV_MODE OR RUNNING_CGAL_AUTO_TEST )
include(CGAL_SetupFlags)
endif()

#CGAL_DATA_DIR, used by `CGAL::data_file_path(filename)` from `CGAL/config.h`
set(CGAL_DATA_DIR "@CGAL_DATA_DIR@")

if(NOT TARGET CGAL::Data)
add_library(CGAL::Data INTERFACE IMPORTED)
if ( NOT "${CGAL_DATA_DIR}" STREQUAL "" )
set_target_properties(CGAL::Data PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "CGAL_DATA_DIR=\"${CGAL_DATA_DIR}\"")
endif()
endif()

include("${CGAL_MODULES_DIR}/CGAL_enable_end_of_configuration_hook.cmake")
12 changes: 12 additions & 0 deletions Installation/cmake/modules/CGALConfig_install.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,16 @@ if( CGAL_DEV_MODE OR RUNNING_CGAL_AUTO_TEST )
# Nov. 2017). -- Laurent Rineau
include(CGAL_SetupFlags)
endif()

#CGAL_DATA_DIR
set(CGAL_DATA_DIR "@CGAL_DATA_DIR@")

if(NOT TARGET CGAL::Data)
add_library(CGAL::Data INTERFACE IMPORTED)
if ( NOT "${CGAL_DATA_DIR}" STREQUAL "" )
set_target_properties(CGAL::Data PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "CGAL_DATA_DIR=\"${CGAL_DATA_DIR}\"")
endif()
endif()

include("${CGAL_MODULES_DIR}/CGAL_enable_end_of_configuration_hook.cmake")
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function(create_single_source_cgal_program firstfile )

add_to_cached_list( CGAL_EXECUTABLE_TARGETS ${exe_name} )

target_link_libraries(${exe_name} PRIVATE CGAL::CGAL)
target_link_libraries(${exe_name} PRIVATE CGAL::CGAL CGAL::Data)
foreach(comp ${CGAL_REQUESTED_COMPONENTS})
if(TARGET CGAL::CGAL_${comp})
target_link_libraries(${exe_name} PRIVATE CGAL::CGAL_${comp})
Expand Down
1 change: 1 addition & 0 deletions Installation/cmake/modules/CGAL_add_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ function(cgal_add_test exe_name)
endif()
if(EXISTS ${cmd_file})
file(STRINGS "${cmd_file}" CMD_LINES)
string(CONFIGURE "${CMD_LINES}" CMD_LINES)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gdamiand prior to here is where the cmake variable CGAL_DATA_DIR must be defined. From what I remember, the config file was not included before. You can start by rechecking this.

This comment was marked as resolved.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put the code in a cmake macro and use the macro wherever we need?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sloriot I tested, adding a message in CGAL_add_test.cmake; CGAL_DATA_DIR is defined.
How can I test one test that uses a cmd file please ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can merge in a detach or temporary branch the other PR and try to run ctest on Surface_mesh_simplification for example.

cmake -DCMAKE_BUILD_TYPE=Debug -DWITH_tests=ON -DBUILD_TESTING=ON $CGAL_DIR
cd test/Surface_mesh_simplification
ctest -j5

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To simplify tests; I updated one test in 1c50254 that uses a .cmd.

I tested locally, it works.

set(ARGS)
# message(STATUS "DEBUG test ${exe_name}")
foreach(CMD_LINE ${CMD_LINES})
Expand Down
59 changes: 59 additions & 0 deletions Installation/include/CGAL/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -737,4 +737,63 @@ namespace cpp11{
/// @}
#include <CGAL/license/lgpl.h>

//----------------------------------------------------------------------//
// Function to define data directory
//----------------------------------------------------------------------//
#include <cstdlib>
#include <string>
#include <fstream>
#include <iostream>

namespace CGAL {

// Returns filename prefixed by the directory of CGAL containing data.
// This directory is either defined in the environement variable CGAL_DATA_DIR,
// otherwise it is taken from the constant CGAL_DATA_DIR (defined in CMake),
// otherwise it is empty (and thus returns filename unmodified).
inline std::string data_file_path(const std::string& filename)
{
const char* cgal_dir=nullptr;

#ifdef _MSC_VER
char* cgal_dir_windows=nullptr;
_dupenv_s( &cgal_dir_windows, nullptr, "CGAL_DATA_DIR");
if (cgal_dir_windows!=nullptr)
{ cgal_dir=cgal_dir_windows; }
#else
cgal_dir=getenv("CGAL_DATA_DIR");
#endif

#ifdef CGAL_DATA_DIR
if (cgal_dir==nullptr)
{ cgal_dir=CGAL_DATA_DIR; }
#endif

std::string cgal_dir_string;
if (cgal_dir!=nullptr)
{ cgal_dir_string=std::string(cgal_dir); }

std::string res=cgal_dir_string;
if (!res.empty() && res.back()!='/')
{ res+=std::string("/"); }
res+=filename;

// Test if the file exists, write a warning otherwise
std::ifstream f(res);
if (!f)
{
std::cerr<<"[WARNING] file "<<res<<" does not exist or cannot be read "
<<"(CGAL_DATA_DIR='"<<cgal_dir_string<<"')."<<std::endl;
}

#ifdef _MSC_VER
if (cgal_dir_windows!=nullptr)
{ free(cgal_dir_windows); }
#endif

return res;
}

} // end namespace CGAL

#endif // CGAL_CONFIG_H
26 changes: 26 additions & 0 deletions Installation/lib/cmake/CGAL/CGALConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,32 @@ else()
endif()
endif()

#set CGAL_DATA_DIR
if (NOT CGAL_DATA_DIR)
if(DEFINED ENV{CGAL_DATA_DIR})
set(CGAL_DATA_DIR $ENV{CGAL_DATA_DIR})
else()
if (EXISTS "${CGAL_ROOT}/data")
set(CGAL_DATA_DIR "${CGAL_ROOT}/data")
else()
if (EXISTS "${CGAL_ROOT}/Data/data")
set(CGAL_DATA_DIR "${CGAL_ROOT}/Data/data")
else()
message("CGAL_ROOT = ${CGAL_ROOT}")
message(WARNING "CGAL_DATA_DIR cannot be deduced, set the variable CGAL_DATA_DIR to set the default value of CGAL::data_file_path()")
endif()
endif()
endif()
endif()

if(NOT TARGET CGAL::Data)
add_library(CGAL::Data INTERFACE IMPORTED)
if ( NOT "${CGAL_DATA_DIR}" STREQUAL "" )
set_target_properties(CGAL::Data PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "CGAL_DATA_DIR=\"${CGAL_DATA_DIR}\"")
endif()
endif()

include(${CGAL_MODULES_DIR}/CGAL_CreateSingleSourceCGALProgram.cmake)
include(${CGAL_MODULES_DIR}/CGAL_Macros.cmake)
include(${CGAL_MODULES_DIR}/CGAL_Common.cmake)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,10 @@ int main(int narg, char** argv)
std::string filename;
if ( narg==1 )
{
filename=std::string("data/points_2");
std::cout<<"No filename given: use data/points_2 by default."<<std::endl;
filename="data/points_2";
std::cout<<"No filename given: use "<<filename<<" by default."<<std::endl;
}
else
filename=std::string(argv[1]);
else { filename=std::string(argv[1]); }

// 1) Compute the Delaunay_triangulation_2.
Triangulation T;
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
data/sphere_20k.xyz
${CGAL_DATA_DIR}/points_3/sphere_20k.xyz
2 changes: 2 additions & 0 deletions Scripts/developer_scripts/autotest_cgal
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ setup_dirs()
CGAL_DIR=`readlink "${CGAL_ROOT}/CGAL-I"`

CGAL_TEST_DIR=${CGAL_DIR}/test
CGAL_DATA_DIR=${CGAL_DIR}/data
export CGAL_DATA_DIR=$(echo "$CGAL_DATA_DIR" | sed -E 's/\/cygdrive\/([a-z])\//\U\1:\//')

if [ ! -d "${CGAL_DIR}/cmake" ]; then
mkdir "${CGAL_DIR}/cmake"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ endif()
file(COPY ${GIT_REPO}/GraphicsView/demo/resources ${GIT_REPO}/GraphicsView/demo/icons
DESTINATION "${release_dir}/cmake/modules/demo")

#copy data
file(COPY ${GIT_REPO}/Data/data DESTINATION "${release_dir}/")

#create VERSION
file(WRITE ${release_dir}/VERSION "${CGAL_VERSION}")

Expand Down Expand Up @@ -296,6 +299,7 @@ file(REMOVE ${release_dir}/include/CGAL/license/package_list.txt)
if(PUBLIC AND NOT TESTSUITE) # we are not creating an internal release.
# Taken from create_new_release.
file(REMOVE_RECURSE ${release_dir}/test)
file(REMOVE_RECURSE ${release_dir}/data/test)
file(REMOVE_RECURSE ${release_dir}/package_info)
file(REMOVE_RECURSE ${release_dir}/developer_scripts)
file(REMOVE_RECURSE ${release_dir}/doc)
Expand All @@ -322,7 +326,7 @@ if (GENERATE_TARBALLS)

#create examples+demos
execute_process(
COMMAND tar cJf ${DESTINATION}/CGAL-${CGAL_VERSION}-examples.tar.xz -C ${DESTINATION} CGAL-${CGAL_VERSION}/examples CGAL-${CGAL_VERSION}/demo
COMMAND tar cJf ${DESTINATION}/CGAL-${CGAL_VERSION}-examples.tar.xz -C ${DESTINATION} CGAL-${CGAL_VERSION}/data CGAL-${CGAL_VERSION}/examples CGAL-${CGAL_VERSION}/demo
RESULT_VARIABLE RESULT_VAR
OUTPUT_VARIABLE OUT_VAR
)
Expand All @@ -336,6 +340,7 @@ if (GENERATE_TARBALLS)
file(REMOVE_RECURSE ${release_dir}/include/CGAL/Test)
file(REMOVE_RECURSE ${release_dir}/include/CGAL/Testsuite/)
endif()
file(REMOVE_RECURSE ${release_dir}/data)
file(REMOVE_RECURSE ${release_dir}/demo)
file(REMOVE_RECURSE ${release_dir}/examples)
file(REMOVE_RECURSE ${release_dir}/scripts)
Expand Down
19 changes: 17 additions & 2 deletions Scripts/developer_scripts/create_cgal_test
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ while [ $1 ]; do
DO_RUN=""
shift; continue
;;
*)
*)
echo "Unknown option: $1"
usage
;;
Expand Down Expand Up @@ -97,6 +97,21 @@ cat << EOF

compile_and_run()
{
if [ -z "\${CGAL_DATA_DIR}" ]; then
if [ -d \${CGAL_DIR}/data ]; then
export CGAL_DATA_DIR=\${CGAL_DIR}/data
else
if [ -d \${CGAL_DIR}/Data/data ]; then
export CGAL_DATA_DIR=\${CGAL_DIR}/Data/data
else
echo "ERROR: Cannot run test script, please set the variable CGAL_DATA_DIR"
exit 1
fi
fi
fi

echo "Runs will be using CGAL_DATA_DIR = \${CGAL_DATA_DIR}"

echo "Compiling \$1 ... "
SUCCESS="y"

Expand All @@ -113,7 +128,7 @@ compile_and_run()
rm -f \$OUTPUTFILE
COMMAND="./\$1"
if [ -f \$1.cmd ] ; then
COMMAND="\$COMMAND \`cat \$1.cmd\`"
COMMAND="\$COMMAND \`eval echo \$(cat \$1.cmd)\`"
fi
if [ -f \$1.cin ] ; then
COMMAND="cat \$1.cin | \$COMMAND"
Expand Down