Skip to content

Commit

Permalink
Merge pull request #1 from sfarrens/updated_cmake
Browse files Browse the repository at this point in the history
updated cmake commands
  • Loading branch information
sfarrens authored Dec 17, 2018
2 parents 255e674 + bcb69ee commit 2c73d4c
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 41 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ignore scripts
*.sh

# Ignore builds
build/
45 changes: 22 additions & 23 deletions fof_cluster_finder/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
cmake_minimum_required(VERSION 2.6)
project(fof_cluster_finder)


message ("BUILDING TYPE = ${CMAKE_BUILD_TYPE} ")
if(CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Release")
endif()
message(STATUS "CMake Build Type: ${CMAKE_BUILD_TYPE}")

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/aux/")

Expand All @@ -11,10 +13,10 @@ find_package(OpenMP REQUIRED)
find_package(Boost COMPONENTS system filesystem unit_test_framework
program_options REQUIRED)

set(CMAKE_CXX_FLAGS_DEBUG "-std=c++0x -g ${OpenMP_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
set(CMAKE_CXX_FLAGS_DEBUG "-std=c++11 -g ${OpenMP_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
set(CMAKE_C_FLAGS_DEBUG "-g ${OpenMP_C_FLAGS} -fprofile-arcs -ftest-coverage ")

set(CMAKE_CXX_FLAGS_RELEASE "-std=c++0x -O3 ${OpenMP_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "-std=c++11 -O3 ${OpenMP_CXX_FLAGS}")
set(CMAKE_C_FLAGS_RELEASE "-O3 ${OpenMP_C_FLAGS}")

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/aux/")
Expand All @@ -34,36 +36,33 @@ set(CPP_SRC
${CPP_SOURCE_DIR}/merge_class.cpp
${CPP_SOURCE_DIR}/option_class.cpp
${CPP_SOURCE_DIR}/zbin_class.cpp
${CPP_SOURCE_DIR}/cat_merge_fileio.cpp
${CPP_SOURCE_DIR}/exceptions.cpp
${CPP_SOURCE_DIR}/cat_merge_fileio.cpp
${CPP_SOURCE_DIR}/exceptions.cpp
${CPP_SOURCE_DIR}/point_class.cpp
${CPP_SOURCE_DIR}/band_matrix.cpp
${CPP_SOURCE_DIR}/spline.cpp
)

include_directories(BEFORE SYSTEM ${CFITSIO_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})

add_executable(main ${CPP_SRC} ${CPP_SOURCE_DIR}/main.cpp)
target_link_libraries(main ${CFITSIO_LIBRARIES} ${Boost_PROGRAM_OPTIONS_LIBRARY_${CMAKE_BUILD_TYPE}})

add_executable(cat_split ${CPP_SRC} ${CPP_SOURCE_DIR}/cat_split.cpp)
target_link_libraries(cat_split ${CFITSIO_LIBRARIES} ${Boost_PROGRAM_OPTIONS_LIBRARY_${CMAKE_BUILD_TYPE}})
set(SOURCE_LIST sfof cat_split cat_merge)

add_executable(cat_merge ${CPP_SRC} ${CPP_SOURCE_DIR}/cat_merge.cpp)
target_link_libraries(cat_merge ${CFITSIO_LIBRARIES} ${Boost_PROGRAM_OPTIONS_LIBRARY_${CMAKE_BUILD_TYPE}})
foreach(program ${SOURCE_LIST})
add_executable(${program} ${CPP_SRC} ${CPP_SOURCE_DIR}/${program}.cpp)
target_link_libraries(${program} ${CFITSIO_LIBRARIES} ${Boost_LIBRARIES})
endforeach(program)

add_executable(test_code ${CPP_SRC} ${CPP_SOURCE_DIR}/test_code.cpp)
target_link_libraries(test_code ${CFITSIO_LIBRARIES} ${Boost_PROGRAM_OPTIONS_LIBRARY_${CMAKE_BUILD_TYPE}})
set(TEST_LIST unit_tests astro_test cosmo_test)

add_executable(unit_test ${CPP_SRC} ${CPP_UNITTEST_SOURCE_DIR}/unit_tests.cpp)
target_link_libraries(unit_test ${CFITSIO_LIBRARIES} ${Boost_PROGRAM_OPTIONS_LIBRARY_${CMAKE_BUILD_TYPE}})
foreach(program ${TEST_LIST})
add_executable(${program} ${CPP_SRC} ${CPP_UNITTEST_SOURCE_DIR}/${program}.cpp)
target_link_libraries(${program} ${CFITSIO_LIBRARIES} ${Boost_LIBRARIES})
endforeach(program)

add_executable(astro_test ${CPP_SRC} ${CPP_UNITTEST_SOURCE_DIR}/astro_test.cpp)
target_link_libraries(astro_test ${CFITSIO_LIBRARIES} ${Boost_PROGRAM_OPTIONS_LIBRARY_${CMAKE_BUILD_TYPE}})
enable_testing()

add_executable(cosmo_test ${CPP_SRC} ${CPP_UNITTEST_SOURCE_DIR}/cosmo_test.cpp)
target_link_libraries(cosmo_test ${CFITSIO_LIBRARIES} ${Boost_PROGRAM_OPTIONS_LIBRARY_${CMAKE_BUILD_TYPE}})

add_test(unit_test unit_test "--config ../examples/unit_test/param_file.unit_test.ini")
# add_test(unit_tests unit_tests "--config ${CMAKE_CURRENT_SOURCE_DIR}/../examples/unit_test/param_file.unit_test.ini")
add_test(astro_test astro_test "--log_level=test_suite")
add_test(cosmo_test cosmo_test "--log_level=test_suite")

INSTALL(TARGETS ${SOURCE_LIST} DESTINATION bin)
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*Main Code*/

#include "main.hpp"
#include "sfof.hpp"

void Main::read_options (int argc, char *argv[]) {
// Function to read code options.
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions fof_cluster_finder/tests/unit/astro_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE MasterTestSuite
#include <boost/test/included/unit_test.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/test/parameterized_test.hpp>
#include "../../src/astro.hpp"
#include "../../src/exceptions.hpp"
Expand Down Expand Up @@ -69,7 +69,7 @@ BOOST_AUTO_TEST_CASE( mean )
std::vector<double> test;
BOOST_CHECK_THROW( astro.mean(test) == 0, BadArgumentException );
for (int i = 0; i < 10; i++) test.push_back(i);
BOOST_CHECK( std::abs(astro.mean(test) - 4.5)
BOOST_CHECK( std::abs(astro.mean(test) - 4.5)
<= std::numeric_limits<double>::epsilon() );
}

Expand All @@ -81,7 +81,7 @@ BOOST_AUTO_TEST_CASE( median )
std::vector<double> test;
BOOST_CHECK_THROW( astro.median(test) == 0, BadArgumentException );
for (int i = 0; i < 10; i++) test.push_back(i);
BOOST_CHECK( std::abs(astro.median(test) - 4.5)
BOOST_CHECK( std::abs(astro.median(test) - 4.5)
<= std::numeric_limits<double>::epsilon() );
}

Expand All @@ -93,7 +93,7 @@ BOOST_AUTO_TEST_CASE( variance )
std::vector<double> test;
BOOST_CHECK_THROW( astro.variance(test) == 0, BadArgumentException );
for (int i = 0; i < 10; i++) test.push_back(i);
BOOST_CHECK( std::abs(astro.variance(test) - 8.25)
BOOST_CHECK( std::abs(astro.variance(test) - 8.25)
<= std::numeric_limits<double>::epsilon() );

}
Expand Down
6 changes: 3 additions & 3 deletions fof_cluster_finder/tests/unit/cosmo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE MasterTestSuite
#include <boost/test/included/unit_test.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/test/parameterized_test.hpp>
#include <limits>
#include "../../src/cosmo.hpp"
Expand Down Expand Up @@ -38,7 +38,7 @@ BOOST_AUTO_TEST_CASE( set_up )
BOOST_AUTO_TEST_CASE( angdidis )
{
BOOST_CHECK( cosmo.angdidis(0.0) == 0.0 );
BOOST_CHECK( std::abs(cosmo.angdidis(1.0) - 0.375)
BOOST_CHECK( std::abs(cosmo.angdidis(1.0) - 0.375)
<= std::numeric_limits<double>::epsilon() );
}

Expand All @@ -47,7 +47,7 @@ BOOST_AUTO_TEST_CASE( angdidis )
*/
BOOST_AUTO_TEST_CASE( angdidis2 )
{
BOOST_CHECK( std::abs(cosmo.angdidis2(0.0, 1.0) - 0.375)
BOOST_CHECK( std::abs(cosmo.angdidis2(0.0, 1.0) - 0.375)
<= std::numeric_limits<double>::epsilon() );
BOOST_CHECK_THROW( cosmo.angdidis2(1.0, 0.0), BadArgumentException );
}
Expand Down
20 changes: 10 additions & 10 deletions fof_cluster_finder/tests/unit/unit_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@

/*
*
*
*
*
*
*
*/

#include <vector>
#include "../../src/main.hpp"
#include "../../src/sfof.hpp"
#include "../../src/exceptions.hpp"

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE MasterTestSuite
#include <boost/test/included/unit_test.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/test/parameterized_test.hpp>

#include <iostream>
Expand All @@ -39,7 +39,7 @@ BOOST_AUTO_TEST_CASE( test_Astro )
BOOST_CHECK_THROW( astro.find_bin(1.0, 2.0, 1.0) == 0, BadArgumentException); // out-of-range values should be handled

/* .. */

}

//void test_Options_and_Galaxies()
Expand All @@ -50,7 +50,7 @@ BOOST_AUTO_TEST_CASE( test_Options_and_Galaxies )
std::vector<Galaxy> gals;

double version_number = 1.0;

BOOST_TEST_MESSAGE("entering case for Options and Galaxy");

opt.read_opts(framework::master_test_suite().argc, framework::master_test_suite().argv, version_number);
Expand All @@ -59,7 +59,7 @@ BOOST_AUTO_TEST_CASE( test_Options_and_Galaxies )
BOOST_CHECK( opt.fof_mode == "phot");
BOOST_CHECK( opt.z_bin_size > 0);
BOOST_CHECK_MESSAGE( opt.input_file.length() != 0, opt.input_file);

/* .. */

Fileio fileio;
Expand All @@ -71,15 +71,15 @@ BOOST_AUTO_TEST_CASE( test_Options_and_Galaxies )
fileio.read_ascii(opt.input_file, opt.fof_mode, opt.z_min, opt.z_max, opt.z_err_max, gals);
else if(opt.input_mode == "fits")
fileio.read_fits(opt.input_file, opt.fof_mode, opt.z_min, opt.z_max, opt.z_err_max, gals);

BOOST_CHECK( gals.size() > 0);

std::vector<int> nums;
for (int i = 0; i < gals.size(); i++)
nums.push_back(gals[i].num);

sort(nums.begin(), nums.end());

for (i = 0; (nums[i]!= nums[i+1]) && (i < nums.size()-1); i++)
;

Expand All @@ -100,5 +100,5 @@ BOOST_AUTO_TEST_SUITE_END ()
// framework::master_test_suite().p_name.value = "Master Unit test";
// framework::master_test_suite().add( BOOST_TEST_CASE( &test_Astro ) );
// framework::master_test_suite().add( BOOST_TEST_CASE( &test_Options_and_Galaxies ) );

// }

0 comments on commit 2c73d4c

Please sign in to comment.