From e8e4d885c5b82d4580b68a36b6f65315c932b771 Mon Sep 17 00:00:00 2001 From: Frederic Bouvier Date: Wed, 26 Oct 2011 22:19:01 +0200 Subject: [PATCH] Build under Windows --- CMakeLists.txt | 40 +++++++++++++++++++++++++++++++ src/Prep/DemChop/testassem.cxx | 4 ---- src/Prep/GDALChop/gdalchop.cxx | 44 +++++++++++++--------------------- src/Prep/Terra/CMakeLists.txt | 3 ++- 4 files changed, 59 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f9b56b2f..6384ff7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,46 @@ if(NOT CMAKE_BUILD_TYPE) FORCE) endif(NOT CMAKE_BUILD_TYPE) + +if (MSVC) + GET_FILENAME_COMPONENT(PARENT_DIR ${PROJECT_SOURCE_DIR} PATH) + if (CMAKE_CL_64) + SET(TEST_3RDPARTY_DIR "${PARENT_DIR}/3rdparty.x64") + else (CMAKE_CL_64) + SET(TEST_3RDPARTY_DIR "${PARENT_DIR}/3rdparty") + endif (CMAKE_CL_64) + if (EXISTS ${TEST_3RDPARTY_DIR}) + set(MSVC_3RDPARTY_ROOT ${PARENT_DIR} CACHE PATH "Location where the third-party dependencies are extracted") + else (EXISTS ${TEST_3RDPARTY_DIR}) + set(MSVC_3RDPARTY_ROOT NOT_FOUND CACHE PATH "Location where the third-party dependencies are extracted") + endif (EXISTS ${TEST_3RDPARTY_DIR}) +else (MSVC) + set(MSVC_3RDPARTY_ROOT NOT_FOUND CACHE PATH "Location where the third-party dependencies are extracted") +endif (MSVC) + +if (MSVC AND MSVC_3RDPARTY_ROOT) + message(STATUS "3rdparty files located in ${MSVC_3RDPARTY_ROOT}") + set( OSG_MSVC "msvc" ) + if (${MSVC_VERSION} EQUAL 1600) + set( OSG_MSVC ${OSG_MSVC}100 ) + else (${MSVC_VERSION} EQUAL 1600) + set( OSG_MSVC ${OSG_MSVC}90 ) + endif (${MSVC_VERSION} EQUAL 1600) + if (CMAKE_CL_64) + set( OSG_MSVC ${OSG_MSVC}-64 ) + set( MSVC_3RDPARTY_DIR 3rdParty.x64 ) + else (CMAKE_CL_64) + set( MSVC_3RDPARTY_DIR 3rdParty ) + endif (CMAKE_CL_64) + + set (CMAKE_LIBRARY_PATH ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenScenegraph/lib ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/SimGear/lib ) + set (CMAKE_INCLUDE_PATH ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/OpenScenegraph/include ${MSVC_3RDPARTY_ROOT}/install/${OSG_MSVC}/SimGear/include) + set (BOOST_ROOT ${MSVC_3RDPARTY_ROOT}/boost_1_44_0) + set (OPENAL_INCLUDE_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include) + set (ALUT_INCLUDE_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/include) + set (OPENAL_LIBRARY_DIR ${MSVC_3RDPARTY_ROOT}/${MSVC_3RDPARTY_DIR}/lib) +endif (MSVC AND MSVC_3RDPARTY_ROOT) + option(ENABLE_GDAL "Set to ON to build TerraGear with GDAL support" ON) # check required dependencies diff --git a/src/Prep/DemChop/testassem.cxx b/src/Prep/DemChop/testassem.cxx index 42ff80fb..bdc2d8c7 100644 --- a/src/Prep/DemChop/testassem.cxx +++ b/src/Prep/DemChop/testassem.cxx @@ -36,10 +36,6 @@ #include #include -#ifdef _MSC_VER -# include -#endif - #include using std::cout; diff --git a/src/Prep/GDALChop/gdalchop.cxx b/src/Prep/GDALChop/gdalchop.cxx index 46dde349..c7172f26 100644 --- a/src/Prep/GDALChop/gdalchop.cxx +++ b/src/Prep/GDALChop/gdalchop.cxx @@ -36,16 +36,15 @@ #include #include #include - -#ifdef _MSC_VER -# include -#endif +#include #include #include #include #include +#include + using std::cout; using std::string; @@ -296,15 +295,11 @@ void write_bucket(const string& work_dir, SGBucket bucket, int span_x, int span_y, int col_step, int row_step, bool compress=true) { - string base = bucket.gen_base_path(); - string path = work_dir + "/" + base; -#ifdef _MSC_VER - fg_mkdir( path.c_str() ); -#else - string command = "mkdir -p " + path; - system( command.c_str() ); -#endif - string array_file = path + "/" + bucket.gen_index_str() + ".arr"; + SGPath path(work_dir); + path.append(bucket.gen_base_path()); + path.create_dir( 0755 ); + + string array_file = path.str() + "/" + bucket.gen_index_str() + ".arr"; FILE *fp; if ( (fp = fopen(array_file.c_str(), "w")) == NULL ) { @@ -359,15 +354,15 @@ void process_bucket(const string& work_dir, SGBucket bucket, span_y=bucket.get_height()*3600/row_step; int cellcount=(span_x+1)*(span_y+1); - int buffer[cellcount]; + boost::scoped_array buffer(new int[cellcount]); - ::memset(buffer,-1,(span_x+1)*(span_y+1)*sizeof(int)); + ::memset(buffer.get(),-1,(span_x+1)*(span_y+1)*sizeof(int)); for (int i=0;iGetBounds(inorth,isouth,ieast,iwest); - images[i]->GetDataChunk(buffer, + images[i]->GetDataChunk(buffer.get(), bwest, bsouth, col_step/3600.0, row_step/3600.0, span_x+1, span_y+1); @@ -397,7 +392,7 @@ void process_bucket(const string& work_dir, SGBucket bucket, /* ...and write it out */ write_bucket(work_dir, bucket, - buffer, + buffer.get(), min_x, min_y, span_x, span_y, col_step, row_step); @@ -412,14 +407,9 @@ int main(int argc, const char **argv) { exit(-1); } - string work_dir = argv[1]; + SGPath work_dir( argv[1] ); -#ifdef _MSC_VER - fg_mkdir( work_dir.c_str() ); -#else - string command = "mkdir -p " + work_dir; - system( command.c_str() ); -#endif + work_dir.create_dir( 0755 ); GDALAllRegister(); @@ -444,7 +434,7 @@ int main(int argc, const char **argv) { const char** tilenames=argv+dashpos+1; const char** datasetnames=argv+2; - ImageInfo *images[datasetcount]; + boost::scoped_array images( new ImageInfo *[datasetcount] ); double north=-1000,south=1000,east=-1000,west=1000; @@ -504,7 +494,7 @@ int main(int argc, const char **argv) { for (int y=0;y<=dy;y++) { SGBucket bucket=sgBucketOffset(west,south,x,y); - process_bucket(work_dir,bucket,images,datasetcount); + process_bucket(work_dir.str(),bucket,images.get(),datasetcount); } } } else { @@ -515,7 +505,7 @@ int main(int argc, const char **argv) { for (int i=0;i