Skip to content

Commit

Permalink
Improvements to SHTfile project inclusion.
Browse files Browse the repository at this point in the history
Will now look for SHTfile inside of EMSoft/ExternalProjects. If it is not found
then it will clone it from github.com/emsoft-org/SHTfile

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
  • Loading branch information
imikejackson committed Oct 14, 2019
1 parent a9d8ccd commit 4f6f972
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 60 deletions.
44 changes: 41 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,43 @@ if (NOT DEFINED CMP_SOURCE_DIR)
endif()
include (${CMP_SOURCE_DIR}/cmpCMakeMacros.cmake )

#get_filename_component(EMsoft_PARENT ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY CACHE)

find_package(Git REQUIRED)

#------------------------------------------------------------------------------
# If the developer has set another EMsoft directory then use that, otherwise look
# for the EMsoft directory at the same level as the EMsoftPrivate directory
if("${SHTfile_SOURCE_DIR}" STREQUAL "")
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ExternalProjects")
file(MAKE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/ExternalProjects")
endif()
set(SHTfile_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ExternalProjects/SHTfile")
message(STATUS "Locating EMsoft Source directory at ${SHTfile_SOURCE_DIR}")
if(EXISTS "${SHTfile_SOURCE_DIR}")
message(STATUS "SHTfile_SOURCE_DIR: ${SHTfile_SOURCE_DIR}")
else()

if(Git_FOUND)
message(STATUS "SHTfile_SOURCE_DIR does not exist at ${SHTfile_SOURCE_DIR}. Attempting to clone it from Github....")
execute_process(COMMAND ${GIT_EXECUTABLE} clone git@github.com:EMsoft-org/SHTfile.git ${SHTfile_SOURCE_DIR}
OUTPUT_VARIABLE CLONE_OUTPUT
RESULT_VARIABLE did_run
ERROR_VARIABLE git_error
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ExternalProjects)
endif()
# One last check. If it does not exist at this point then we simply Abort CMake
if(NOT EXISTS "${SHTfile_SOURCE_DIR}")
message(FATAL_ERROR "SHTfile_SOURCE_DIR does not exist. We attempted to clone it from the GitHub repo but that also seemed\
to fail. EMsoft can not proceed without the SHTfile directory. Please ask a EMsoft developer for more\
information about this error. Can you access http://github.com/EMsoft-org/SHTfile.git is\
a firewall blocking the 'git' protocol? ")
endif()

endif()
endif()


# Next up, Set the version of EMsoft that is used through out the project.

set(EMsoft_VER_MAJOR "5")
Expand Down Expand Up @@ -180,9 +217,6 @@ if("${EMsoftSearchDirs}" STREQUAL "")

endif()




# Set the Application Name to with the correct icons and badges
set(CMP_HEADER_DIR ${EMsoft_BINARY_DIR})
set(PROJECT_RESOURCES_DIR "${EMsoft_SOURCE_DIR}/resources")
Expand Down Expand Up @@ -270,6 +304,10 @@ OPTION(EMsoft_ENABLE_TESTING "Compile the test programs" ON)
set(EMsoft_TESTING_DIR "${EMsoft_BINARY_DIR}/Testing")


# -----------------------------------------------------------------------
# Build SHTfile Project
# -----------------------------------------------------------------------
add_subdirectory(${SHTfile_SOURCE_DIR} ${EMsoft_BINARY_DIR}/SHTfile)

# -----------------------------------------------------------------------
# Set a Global Prefix where everthing is going to get intalled. For OS X we are
Expand Down
44 changes: 24 additions & 20 deletions Source/EMsoftLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,27 @@ add_custom_target(EMsoftLib_Generate_StringConstants ALL



if(0)
# fetch SHT file format content
# this could be done with a git submodule but the user would have to call:
# git submodule update
# git clone --recursive
# which is a bit annoying
include(FetchContent)
FetchContent_Declare(
SHTfile
GIT_REPOSITORY "https://github.com/EMsoft-org/SHTfile"
# GIT_TAG "v3.1.2" # just get the most recent version for now
# GIT_PROGRESS TRUE # its currently only 1 file, we probably don't need to print out progress
)
# set(FETCHCONTENT_QUIET NO) # again only 1 file
FetchContent_MakeAvailable(SHTfile)
FetchContent_GetProperties(SHTfile BINARY_DIR SHTfile_BINARY_DIR)
include_directories(${SHTfile_BINARY_DIR})
endif()



# fetch SHT file format content
# this could be done with a git submodule but the user would have to call:
# git submodule update
# git clone --recursive
# which is a bit annoying
include(FetchContent)
FetchContent_Declare(
SHTfile
GIT_REPOSITORY "https://github.com/EMsoft-org/SHTfile"
# GIT_TAG "v3.1.2" # just get the most recent version for now
# GIT_PROGRESS TRUE # its currently only 1 file, we probably don't need to print out progress
)
# set(FETCHCONTENT_QUIET NO) # again only 1 file
FetchContent_MakeAvailable(SHTfile)
FetchContent_GetProperties(SHTfile BINARY_DIR SHTfile_BINARY_DIR)
include_directories(${SHTfile_BINARY_DIR})


#------------------------------------------------------------------------------
Expand Down Expand Up @@ -131,6 +135,7 @@ set(EMsoftLib_C_SRCS

set(EMsoftLib_Cpp_SRCS
${EMsoftLib_SOURCE_DIR}/sht_file.cpp
${EMSphInx_BINARY_DIR}/sht_file.hpp
)

if(NOT WIN32 AND BUILD_SHARED_LIBS)
Expand Down Expand Up @@ -168,17 +173,15 @@ set_target_properties (EMsoftLib_Cpp PROPERTIES
# Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}
FOLDER EMsoftPublic
)

target_include_directories(EMsoftLib_Cpp PRIVATE ${EMSphInx_BINARY_DIR})

add_library(EMsoftLib ${LIB_TYPE} ${EMsoftLib_SRCS})
target_link_libraries(EMsoftLib
EMsoftLib_C
EMsoftLib_Cpp
jsonfortran
${OpenCL_LIBRARY}
bcls::bcls


bcls::bcls
)
if (Fortran_COMPILER_NAME MATCHES "ifort.*")
target_link_libraries(EMsoftLib
Expand All @@ -196,6 +199,7 @@ endif()


target_include_directories(EMsoftLib PUBLIC ${CLFortran_INCLUDE_DIRS} ${FFTW3_INCLUDE_DIR})

set_target_properties (EMsoftLib PROPERTIES
LINKER_LANGUAGE Fortran
# Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}
Expand Down
69 changes: 32 additions & 37 deletions Source/EMsoftLib/sht_file.cpp
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright (c) 2019-2019, De Graef Group, Carnegie Mellon University *
* All rights reserved. *
* *
* Author: William C. Lenthe *
* *
* This package is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of the *
* License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, check the Free Software Foundation *
* website: <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html> *
* *
* *
* Interested in a commercial license? Contact: *
* *
* Center for Technology Transfer and Enterprise Creation *
* 4615 Forbes Avenue, Suite 302 *
* Pittsburgh, PA 15213 *
* *
* phone. : 412.268.7393 *
* email : innovation@cmu.edu *
* website: https://www.cmu.edu/cttec/ *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
* Copyright (c) 2018-2019, Marc De Graef Research Group/Carnegie Mellon University *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without *
* modification, are permitted provided that the following conditions are met: *
* *
* - Redistributions of source code must retain the above copyright notice, this *
* list of conditions and the following disclaimer. *
* - Redistributions in binary form must reproduce the above copyright notice, *
* this list of conditions and the following disclaimer in the documentation *
* and/or other materials provided with the distribution. *
* - Neither the copyright holder nor the names of its *
* contributors may be used to endorse or promote products derived from *
* this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" *
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE *
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE *
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL *
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR *
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER *
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, *
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE *
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
* *
*/

#include "sht_file.hpp"

Expand All @@ -48,10 +43,10 @@ extern "C" {
//@param iprm: integer parameters {# electrons, electron multiplier, numsx, npx, latgridtype}
//@param bw : bandwidth
//@param alm: actual harmonics (uncompressed format)
int writeSHTfile_(char * fn, char const * nt, char const * doi,
int32_t * sgN, int32_t * sgS, int32_t * nAt, int32_t * aTy, float * aCd, float * lat,
float * fprm, int32_t * iprm,
int32_t * bw,double * alm) {
int writeSHTfile_(char* fn, const char* nt, const char* doi,
int32_t* sgN, int32_t* sgS, int32_t* nAt, int32_t* aTy, float* aCd, float* lat,
float* fprm, int32_t* iprm,
int32_t* bw,double* alm) {
return sht::File::EMsoftEBSDRet(fn, nt, doi, *sgN, *sgS, *nAt, aTy, aCd, lat, fprm, iprm, *bw, alm);
}
}

0 comments on commit 4f6f972

Please sign in to comment.