diff options
25 files changed, 420 insertions, 85 deletions
diff --git a/Help/release/dev/java-updates.rst b/Help/release/dev/java-updates.rst index b777807..8fd4ed6 100644 --- a/Help/release/dev/java-updates.rst +++ b/Help/release/dev/java-updates.rst @@ -11,3 +11,6 @@ java-updates * The :module:`UseJava` module ``install_jar`` function learned new ``DESTINATION`` and ``COMPONENT`` options to specify the corresponding :command:`install` command options. + +* The :module:`UseJava` module gained a new ``create_javah`` + function to create C headers from Java classes. diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake index d31fea3..6958a2a 100644 --- a/Modules/FindJNI.cmake +++ b/Modules/FindJNI.cmake @@ -156,6 +156,9 @@ JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES /usr/local/jre-1.7.0/lib/{libarch} /usr/local/jdk-1.6.0/jre/lib/{libarch} /usr/local/jre-1.6.0/lib/{libarch} + # SuSE specific paths for default JVM + /usr/lib64/jvm/java/jre/lib/{libarch} + /usr/lib64/jvm/jre/lib/{libarch} ) set(JAVA_JVM_LIBRARY_DIRECTORIES) @@ -164,6 +167,9 @@ foreach(dir ${JAVA_AWT_LIBRARY_DIRECTORIES}) "${dir}" "${dir}/client" "${dir}/server" + # IBM SDK, Java Technology Edition, specific paths + "${dir}/j9vm" + "${dir}/default" ) endforeach() @@ -193,6 +199,8 @@ list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES # OpenBSD specific path for default JVM /usr/local/jdk-1.7.0/include /usr/local/jdk-1.6.0/include + # SuSE specific paths for default JVM + /usr/lib64/jvm/java/include ) foreach(JAVA_PROG "${JAVA_RUNTIME}" "${JAVA_COMPILE}" "${JAVA_ARCHIVE}") diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake index 4e4810a..bb085ac 100644 --- a/Modules/Platform/Darwin.cmake +++ b/Modules/Platform/Darwin.cmake @@ -53,7 +53,7 @@ set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-dynamiclib -Wl,-headerpad_max_install_ set(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "-bundle -Wl,-headerpad_max_install_names") set(CMAKE_SHARED_MODULE_LOADER_C_FLAG "-Wl,-bundle_loader,") set(CMAKE_SHARED_MODULE_LOADER_CXX_FLAG "-Wl,-bundle_loader,") -set(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib" ".so" ".a") +set(CMAKE_FIND_LIBRARY_SUFFIXES ".tbd" ".dylib" ".so" ".a") # hack: if a new cmake (which uses CMAKE_INSTALL_NAME_TOOL) runs on an old build tree # (where install_name_tool was hardcoded) and where CMAKE_INSTALL_NAME_TOOL isn't in the cache diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake index c61591d..dced6ec 100644 --- a/Modules/UseJava.cmake +++ b/Modules/UseJava.cmake @@ -309,6 +309,65 @@ # # # if you don't set the INSTALLPATH. +# +# :: +# +# create_javah(TARGET <target> +# GENERATED_FILES <VAR> +# CLASSES <class>... +# [CLASSPATH <classpath>...] +# [DEPENDS <depend>...] +# [OUTPUT_NAME <path>|OUTPUT_DIR <path>] +# ) +# +# Create C header files from java classes. These files provide the connective glue +# that allow your Java and C code to interact. +# +# There are two main signatures for create_javah. The first signature +# returns generated files throught variable specified by GENERATED_FILES option: +# +# :: +# +# Example: +# Create_javah(GENERATED_FILES files_headers +# CLASSES org.cmake.HelloWorld +# CLASSPATH hello.jar +# ) +# +# +# +# The second signature for create_javah creates a target which encapsulates +# header files generation. +# +# :: +# +# Example: +# Create_javah(TARGET target_headers +# CLASSES org.cmake.HelloWorld +# CLASSPATH hello.jar +# ) +# +# +# +# Both signatures share same options. +# +# ``CLASSES <class>...`` +# Specifies Java classes used to generate headers. +# +# ``CLASSPATH <classpath>...`` +# Specifies various paths to look up classes. Here .class files, jar files or targets +# created by command add_jar can be used. +# +# ``DEPENDS <depend>...`` +# Targets on which the javah target depends +# +# ``OUTPUT_NAME <path>`` +# Concatenates the resulting header files for all the classes listed by option CLASSES +# into <path>. Same behavior as option '-o' of javah tool. +# +# ``OUTPUT_DIR <path>`` +# Sets the directory where the header files will be generated. Same behavior as option +# '-d' of javah tool. If not specified, ${CMAKE_CURRENT_BINARY_DIR} is used as output directory. #============================================================================= # Copyright 2013 OpenGamma Ltd. <graham@opengamma.com> @@ -1131,3 +1190,101 @@ function(create_javadoc _target) DESTINATION ${_javadoc_installpath} ) endfunction() + +function (create_javah) + cmake_parse_arguments(_create_javah + "" + "TARGET;GENERATED_FILES;OUTPUT_NAME;OUTPUT_DIR" + "CLASSES;CLASSPATH;DEPENDS" + ${ARGN}) + + # ckeck parameters + if (NOT _create_javah_TARGET AND NOT _create_javah_GENERATED_FILES) + message (FATAL_ERROR "create_javah: TARGET or GENERATED_FILES must be specified.") + endif() + if (_create_javah_OUTPUT_NAME AND _create_javah_OUTPUT_DIR) + message (FATAL_ERROR "create_javah: OUTPUT_NAME and OUTPUT_DIR are mutually exclusive.") + endif() + + if (NOT _create_javah_CLASSES) + message (FATAL_ERROR "create_javah: CLASSES is a required parameter.") + endif() + + set (_output_files) + if (WIN32 AND NOT CYGWIN AND CMAKE_HOST_SYSTEM_NAME MATCHES "Windows") + set(_classpath_sep ";") + else () + set(_classpath_sep ":") + endif() + + # handle javah options + set (_javah_options) + + if (_create_javah_CLASSPATH) + # CLASSPATH can specify directories, jar files or targets created with add_jar command + set (_classpath) + foreach (_path IN LISTS _create_javah_CLASSPATH) + if (TARGET ${_path}) + get_target_property (_jar_path ${_path} JAR_FILE) + if (_jar_path) + list (APPEND _classpath "${_jar_path}") + list (APPEND _create_javah_DEPENDS "${_path}") + else() + message(SEND_ERROR "create_javah: CLASSPATH target ${_path} is not a jar.") + endif() + elseif (EXISTS "${_path}") + list (APPEND _classpath "${_path}") + if (NOT IS_DIRECTORY "${_path}") + list (APPEND _create_javah_DEPENDS "${_path}") + endif() + else() + message(SEND_ERROR "create_javah: CLASSPATH entry ${_path} does not exist.") + endif() + endforeach() + string (REPLACE ";" "${_classpath_sep}" _classpath "${_classpath}") + list (APPEND _javah_options -classpath ${_classpath}) + endif() + + if (_create_javah_OUTPUT_DIR) + list (APPEND _javah_options -d "${_create_javah_OUTPUT_DIR}") + endif() + + if (_create_javah_OUTPUT_NAME) + list (APPEND _javah_options -o "${_create_javah_OUTPUT_NAME}") + set (_output_files "${_create_javah_OUTPUT_NAME}") + + get_filename_component (_create_javah_OUTPUT_DIR "${_create_javah_OUTPUT_NAME}" DIRECTORY) + get_filename_component (_create_javah_OUTPUT_DIR "${_create_javah_OUTPUT_DIR}" ABSOLUTE) + endif() + + if (NOT _create_javah_OUTPUT_DIR) + set (_create_javah_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}") + endif() + + if (NOT _create_javah_OUTPUT_NAME) + # compute output names + foreach (_class IN LISTS _create_javah_CLASSES) + string (REPLACE "." "_" _c_header "${_class}") + set (_c_header "${_create_javah_OUTPUT_DIR}/${_c_header}.h") + list (APPEND _output_files "${_c_header}") + endforeach() + endif() + + # finalize custom command arguments + if (_create_javah_DEPENDS) + list (INSERT _create_javah_DEPENDS 0 DEPENDS) + endif() + + add_custom_command (OUTPUT ${_output_files} + COMMAND "${Java_JAVAH_EXECUTABLE}" ${_javah_options} -jni ${_create_javah_CLASSES} + ${_create_javah_DEPENDS} + WORKING_DIRECTORY ${_create_javah_OUTPUT_DIR} + COMMENT "Building C header files from classes...") + + if (_create_javah_TARGET) + add_custom_target (${_create_javah_TARGET} ALL DEPENDS ${_output_files}) + endif() + if (_create_javah_GENERATED_FILES) + set (${_create_javah_GENERATED_FILES} ${_output_files} PARENT_SCOPE) + endif() +endfunction() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 4e0b28c..1894b69 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 3) -set(CMake_VERSION_PATCH 20150825) +set(CMake_VERSION_PATCH 20150827) #set(CMake_VERSION_RC 1) diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index 591a2cd..7da334e 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -115,7 +115,9 @@ void CCONV cmAddCacheDefinition(void *arg, const char* name, const char* CCONV cmGetProjectName(void *arg) { cmMakefile *mf = static_cast<cmMakefile *>(arg); - return mf->GetProjectName(); + static std::string name; + name = mf->GetProjectName(); + return name.c_str(); } const char* CCONV cmGetHomeDirectory(void *arg) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 503c455..bdd5b5a 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2041,24 +2041,37 @@ void cmGlobalGenerator::SetConfiguredFilesPath(cmGlobalGenerator* gen) } } -bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, - cmLocalGenerator* gen) const +bool cmGlobalGenerator::IsExcluded(cmState::Snapshot const& rootSnp, + cmState::Snapshot const& snp_) const { - if(!gen || gen == root) + cmState::Snapshot snp = snp_; + while (snp.IsValid()) { - // No directory excludes itself. - return false; - } + if(snp == rootSnp) + { + // No directory excludes itself. + return false; + } - if(gen->GetMakefile()->GetPropertyAsBool("EXCLUDE_FROM_ALL")) - { - // This directory is excluded from its parent. - return true; + if(snp.GetDirectory().GetPropertyAsBool("EXCLUDE_FROM_ALL")) + { + // This directory is excluded from its parent. + return true; + } + snp = snp.GetBuildsystemDirectoryParent(); } + return false; +} + +bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, + cmLocalGenerator* gen) const +{ + assert(gen); + + cmState::Snapshot rootSnp = root->GetStateSnapshot(); + cmState::Snapshot snp = gen->GetStateSnapshot(); - // This directory is included in its parent. Check whether the - // parent is excluded. - return this->IsExcluded(root, gen->GetParent()); + return this->IsExcluded(rootSnp, snp); } bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, @@ -2070,12 +2083,9 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root, // This target is excluded from its directory. return true; } - else - { - // This target is included in its directory. Check whether the - // directory is excluded. - return this->IsExcluded(root, target->GetLocalGenerator()); - } + // This target is included in its directory. Check whether the + // directory is excluded. + return this->IsExcluded(root, target->GetLocalGenerator()); } void @@ -2102,18 +2112,19 @@ void cmGlobalGenerator::FillProjectMap() for(i = 0; i < this->LocalGenerators.size(); ++i) { // for each local generator add all projects - cmLocalGenerator *lg = this->LocalGenerators[i]; + cmState::Snapshot snp = this->LocalGenerators[i]->GetStateSnapshot(); std::string name; do { - if (name != lg->GetMakefile()->GetProjectName()) + std::string snpProjName = snp.GetProjectName(); + if (name != snpProjName) { - name = lg->GetMakefile()->GetProjectName(); + name = snpProjName; this->ProjectMap[name].push_back(this->LocalGenerators[i]); } - lg = lg->GetParent(); + snp = snp.GetBuildsystemDirectoryParent(); } - while (lg); + while (snp.IsValid()); } } diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 3403cf9..21cbd44 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -396,6 +396,8 @@ protected: // has been populated. void FillProjectMap(); void CheckLocalGenerators(); + bool IsExcluded(cmState::Snapshot const& root, + cmState::Snapshot const& snp) const; bool IsExcluded(cmLocalGenerator* root, cmLocalGenerator* gen) const; bool IsExcluded(cmLocalGenerator* root, cmGeneratorTarget* target) const; virtual void InitializeProgressMarks() {} diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index b240924..92bef67 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -495,12 +495,12 @@ cmGlobalUnixMakefileGenerator3 // The directory-level rule should depend on the directory-level // rules of the subdirectories. - for(std::vector<cmLocalGenerator*>::iterator sdi = - lg->GetChildren().begin(); sdi != lg->GetChildren().end(); ++sdi) + std::vector<cmState::Snapshot> children + = lg->GetMakefile()->GetStateSnapshot().GetChildren(); + for(std::vector<cmState::Snapshot>::const_iterator + ci = children.begin(); ci != children.end(); ++ci) { - cmLocalUnixMakefileGenerator3* slg = - static_cast<cmLocalUnixMakefileGenerator3*>(*sdi); - std::string subdir = slg->GetMakefile()->GetCurrentBinaryDirectory(); + std::string subdir = ci->GetDirectory().GetCurrentBinary(); subdir += "/"; subdir += pass; depends.push_back(subdir); @@ -936,14 +936,25 @@ void cmGlobalUnixMakefileGenerator3::InitializeProgressMarks() cmGeneratorTarget* gt = this->GetGeneratorTarget(&target); + cmLocalGenerator* tlg = gt->GetLocalGenerator(); + + if(gt->GetType() == cmTarget::INTERFACE_LIBRARY + || gt->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) + { + continue; + } + + cmState::Snapshot csnp = lg->GetStateSnapshot(); + cmState::Snapshot tsnp = tlg->GetStateSnapshot(); + // Consider the directory containing the target and all its // parents until something excludes the target. - for(cmLocalGenerator* clg = lg; clg && !this->IsExcluded(clg, gt); - clg = clg->GetParent()) + for( ; csnp.IsValid() && !this->IsExcluded(csnp, tsnp); + csnp = csnp.GetBuildsystemDirectoryParent()) { // This local generator includes the target. std::set<cmGeneratorTarget const*>& targetSet = - this->DirectoryTargetsMap[clg->GetStateSnapshot()]; + this->DirectoryTargetsMap[csnp]; targetSet.insert(gt); // Add dependencies of the included target. An excluded diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index edb644d..1e8fd3e 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -50,10 +50,6 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, assert(snapshot.IsValid()); this->GlobalGenerator = gg; this->Parent = parent; - if (parent) - { - parent->AddChild(this); - } this->Makefile = new cmMakefile(this); @@ -199,18 +195,16 @@ void cmLocalGenerator::GenerateTestFiles() (*gi)->Compute(this); (*gi)->Generate(fout, config, configurationTypes); } - if (!this->Children.empty()) + size_t i; + std::vector<cmState::Snapshot> children + = this->Makefile->GetStateSnapshot().GetChildren(); + for(i = 0; i < children.size(); ++i) { - size_t i; - for(i = 0; i < this->Children.size(); ++i) - { - // TODO: Use add_subdirectory instead? - fout << "subdirs("; - std::string outP = - this->Children[i]->GetMakefile()->GetCurrentBinaryDirectory(); - fout << this->Convert(outP,START_OUTPUT); - fout << ")" << std::endl; - } + // TODO: Use add_subdirectory instead? + fout << "subdirs("; + std::string outP = children[i].GetDirectory().GetCurrentBinary(); + fout << this->Convert(outP,START_OUTPUT); + fout << ")" << std::endl; } } @@ -416,16 +410,18 @@ void cmLocalGenerator::GenerateInstallRules() this->GenerateTargetInstallRules(fout, config, configurationTypes); // Include install scripts from subdirectories. - if(!this->Children.empty()) + std::vector<cmState::Snapshot> children + = this->Makefile->GetStateSnapshot().GetChildren(); + if(!children.empty()) { fout << "if(NOT CMAKE_INSTALL_LOCAL_ONLY)\n"; fout << " # Include the install script for each subdirectory.\n"; - for(std::vector<cmLocalGenerator*>::const_iterator - ci = this->Children.begin(); ci != this->Children.end(); ++ci) + for(std::vector<cmState::Snapshot>::const_iterator + ci = children.begin(); ci != children.end(); ++ci) { - if(!(*ci)->GetMakefile()->GetPropertyAsBool("EXCLUDE_FROM_ALL")) + if(!ci->GetDirectory().GetPropertyAsBool("EXCLUDE_FROM_ALL")) { - std::string odir = (*ci)->GetMakefile()->GetCurrentBinaryDirectory(); + std::string odir = ci->GetDirectory().GetCurrentBinary(); cmSystemTools::ConvertToUnixSlashes(odir); fout << " include(\"" << odir << "/cmake_install.cmake\")" << std::endl; @@ -2368,25 +2364,22 @@ void cmLocalGenerator::AppendFeatureOptions( const char* cmLocalGenerator::GetFeature(const std::string& feature, const std::string& config) { + std::string featureName = feature; // TODO: Define accumulation policy for features (prepend, append, replace). // Currently we always replace. if(!config.empty()) { - std::string featureConfig = feature; - featureConfig += "_"; - featureConfig += cmSystemTools::UpperCase(config); - if(const char* value = this->Makefile->GetProperty(featureConfig)) + featureName += "_"; + featureName += cmSystemTools::UpperCase(config); + } + cmState::Snapshot snp = this->StateSnapshot; + while(snp.IsValid()) + { + if(const char* value = snp.GetDirectory().GetProperty(featureName)) { return value; } - } - if(const char* value = this->Makefile->GetProperty(feature)) - { - return value; - } - if(cmLocalGenerator* parent = this->GetParent()) - { - return parent->GetFeature(feature, config); + snp = snp.GetBuildsystemDirectoryParent(); } return 0; } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 1c18788..915814b 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -89,11 +89,6 @@ public: ///! set/get the parent generator cmLocalGenerator* GetParent() const {return this->Parent;} - ///! set/get the children - void AddChild(cmLocalGenerator* g) { this->Children.push_back(g); } - std::vector<cmLocalGenerator*>& GetChildren() { return this->Children; } - - void AddArchitectureFlags(std::string& flags, cmGeneratorTarget const* target, const std::string&lang, const std::string& config); @@ -349,7 +344,6 @@ protected: cmState::Snapshot StateSnapshot; cmGlobalGenerator *GlobalGenerator; cmLocalGenerator* Parent; - std::vector<cmLocalGenerator*> Children; std::map<std::string, std::string> UniqueObjectNamesMap; std::string::size_type ObjectPathMax; std::set<std::string> ObjectMaxPathViolations; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 1550c7b..4a4663a 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1518,7 +1518,7 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent) parent->GetProperty("LINK_DIRECTORIES")); // the initial project name - this->ProjectName = parent->ProjectName; + this->SetProjectName(parent->GetProjectName()); // Copy include regular expressions. this->ComplainFileRegularExpression = parent->ComplainFileRegularExpression; @@ -2037,11 +2037,15 @@ void cmMakefile::RemoveCacheDefinition(const std::string& name) this->GetState()->RemoveCacheEntry(name); } -void cmMakefile::SetProjectName(const char* p) +void cmMakefile::SetProjectName(std::string const& p) { - this->ProjectName = p; + this->StateSnapshot.SetProjectName(p); } +std::string cmMakefile::GetProjectName() const +{ + return this->StateSnapshot.GetProjectName(); +} void cmMakefile::AddGlobalLinkInformation(const std::string& name, cmTarget& target) diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 1f8a054..f3839aa 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -272,15 +272,12 @@ public: /** * Specify the name of the project for this build. */ - void SetProjectName(const char*); + void SetProjectName(std::string const& name); /** * Get the name of the project for this build. */ - const char* GetProjectName() const - { - return this->ProjectName.c_str(); - } + std::string GetProjectName() const; /** Get the configurations to be generated. */ std::string GetConfigurations(std::vector<std::string>& configs, @@ -811,8 +808,6 @@ protected: mutable std::set<cmListFileContext> CMP0054ReportedIds; - std::string ProjectName; // project name - // libraries, classes, and executables mutable cmTargets Targets; #if defined(CMAKE_BUILD_WITH_CMAKE) diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 46d7e01..7123125 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -20,7 +20,7 @@ bool cmProjectCommand this->SetError("PROJECT called with incorrect number of arguments"); return false; } - this->Makefile->SetProjectName(args[0].c_str()); + this->Makefile->SetProjectName(args[0]); std::string bindir = args[0]; bindir += "_BINARY_DIR"; diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 53fdae0..b30c10b 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -75,7 +75,11 @@ struct cmState::BuildsystemDirectoryStateType std::vector<std::string> CompileOptions; std::vector<cmListFileBacktrace> CompileOptionsBacktraces; + std::string ProjectName; + cmPropertyMap Properties; + + std::vector<cmState::Snapshot> Children; }; cmState::cmState(cmake* cm) @@ -274,6 +278,7 @@ cmState::Snapshot cmState::Reset() it->CompileOptionsBacktraces.clear(); it->DirectoryEnd = pos; it->Properties.clear(); + it->Children.clear(); } this->PolicyStack.Clear(); @@ -800,7 +805,9 @@ cmState::CreateBuildsystemDirectorySnapshot(Snapshot originSnapshot, pos->Parent = origin; pos->Root = origin; pos->Vars = this->VarTree.Extend(origin); - return cmState::Snapshot(this, pos); + cmState::Snapshot snapshot = cmState::Snapshot(this, pos); + originSnapshot.Position->BuildSystemDirectory->Children.push_back(snapshot); + return snapshot; } cmState::Snapshot @@ -938,6 +945,11 @@ cmState::Snapshot::Snapshot(cmState* state) { } +std::vector<cmState::Snapshot> cmState::Snapshot::GetChildren() +{ + return this->Position->BuildSystemDirectory->Children; +} + cmState::Snapshot::Snapshot(cmState* state, PositionType position) : State(state), Position(position) @@ -1312,6 +1324,16 @@ cmState::Directory cmState::Snapshot::GetDirectory() const return Directory(this->Position->BuildSystemDirectory, *this); } +void cmState::Snapshot::SetProjectName(const std::string& name) +{ + this->Position->BuildSystemDirectory->ProjectName = name; +} + +std::string cmState::Snapshot::GetProjectName() const +{ + return this->Position->BuildSystemDirectory->ProjectName; +} + cmState::Directory::Directory( cmLinkedTree<BuildsystemDirectoryStateType>::iterator iter, const cmState::Snapshot& snapshot) @@ -1701,3 +1723,13 @@ std::vector<std::string> cmState::Directory::GetPropertyKeys() const } return keys; } + +bool operator==(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs) +{ + return lhs.Position == rhs.Position; +} + +bool operator!=(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs) +{ + return lhs.Position != rhs.Position; +} diff --git a/Source/cmState.h b/Source/cmState.h index e503cd2..99e537c 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -65,6 +65,8 @@ public: void SetListFile(std::string const& listfile); std::string GetExecutionListFile() const; + + std::vector<Snapshot> GetChildren(); std::string GetEntryPointCommand() const; long GetEntryPointLine() const; @@ -86,6 +88,9 @@ public: Directory GetDirectory() const; + void SetProjectName(std::string const& name); + std::string GetProjectName() const; + struct StrictWeakOrder { bool operator()(const cmState::Snapshot& lhs, @@ -93,6 +98,10 @@ public: }; private: + friend bool operator==(const cmState::Snapshot& lhs, + const cmState::Snapshot& rhs); + friend bool operator!=(const cmState::Snapshot& lhs, + const cmState::Snapshot& rhs); friend class cmState; friend class Directory; friend struct StrictWeakOrder; @@ -314,4 +323,7 @@ private: bool MSYSShell; }; +bool operator==(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs); +bool operator!=(const cmState::Snapshot& lhs, const cmState::Snapshot& rhs); + #endif diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 35b29bf..801d7e8 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -3036,6 +3036,31 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --build-options ${build_options} --test-command ${JAVA_RUNTIME} -classpath hello2.jar HelloWorld) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJarSourceList") + + # For next test, java tool must have same architecture as toolchain + math(EXPR _object_mode "${CMAKE_SIZEOF_VOID_P} * 8") + execute_process( + COMMAND "${Java_JAVA_EXECUTABLE}" -d${_object_mode} -version + OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE _result + ) + if(_result EQUAL 0) + if(CMAKE_CONFIGURATION_TYPES) + set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah/$<CONFIGURATION>) + else() + set (JAVAH_LIBRARY_PATH ${CMake_BINARY_DIR}/Tests/JavaJavah) + endif() + add_test(NAME Java.Javah COMMAND ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/JavaJavah" + "${CMake_BINARY_DIR}/Tests/JavaJavah" + ${build_generator_args} + --build-project helloJavah + --build-two-config + --build-run-dir "${CMake_BINARY_DIR}/Tests/JavaJavah/" + --build-options ${build_options} + --test-command ${JAVA_RUNTIME} -Djava.library.path=${JAVAH_LIBRARY_PATH} -classpath hello3.jar HelloWorld2) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/JavaJavah") + endif() endif() endif() endif() diff --git a/Tests/JavaJavah/B.cpp b/Tests/JavaJavah/B.cpp new file mode 100644 index 0000000..2666757 --- /dev/null +++ b/Tests/JavaJavah/B.cpp @@ -0,0 +1,10 @@ + +#include <jni.h> +#include <stdio.h> + +#include "B.h" + +JNIEXPORT void JNICALL Java_B_printName(JNIEnv *, jobject) +{ + printf("B\n"); +} diff --git a/Tests/JavaJavah/B.java b/Tests/JavaJavah/B.java new file mode 100644 index 0000000..d731f39 --- /dev/null +++ b/Tests/JavaJavah/B.java @@ -0,0 +1,19 @@ +class B +{ + public B() + { + } + + public native void printName(); + + static { + try { + + System.loadLibrary("B"); + + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load.\n" + e); + System.exit(1); + } + } +} diff --git a/Tests/JavaJavah/CMakeLists.txt b/Tests/JavaJavah/CMakeLists.txt new file mode 100644 index 0000000..83b0ad0 --- /dev/null +++ b/Tests/JavaJavah/CMakeLists.txt @@ -0,0 +1,20 @@ +project(helloJavah Java CXX) + +cmake_minimum_required (VERSION 2.6) +set(CMAKE_VERBOSE_MAKEFILE 1) + +find_package(Java COMPONENTS Development) +include (UseJava) + +# JNI support +find_package(JNI) + +add_jar(hello3 B.java HelloWorld2.java) +create_javah(TARGET B_javah CLASSES B CLASSPATH hello3) + +add_library(B SHARED B.cpp) +add_dependencies(B B_javah) + +target_include_directories(B PRIVATE ${CMAKE_CURRENT_BINARY_DIR} + ${JAVA_INCLUDE_PATH} + ${JAVA_INCLUDE_PATH2}) diff --git a/Tests/JavaJavah/HelloWorld2.java b/Tests/JavaJavah/HelloWorld2.java new file mode 100644 index 0000000..faf7277 --- /dev/null +++ b/Tests/JavaJavah/HelloWorld2.java @@ -0,0 +1,10 @@ +class HelloWorld2 +{ + public static void main(String args[]) + { + B b; + b = new B(); + b.printName(); + System.out.println("Hello World!"); + } +} diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index ef81739..1151abf 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -39,3 +39,9 @@ if(NOT XCODE_VERSION VERSION_LESS 5) unset(RunCMake_TEST_NO_CLEAN) unset(RunCMake_TEST_OPTIONS) endif() + +if(NOT XCODE_VERSION VERSION_LESS 7) + set(RunCMake_TEST_OPTIONS "-DCMAKE_TOOLCHAIN_FILE=${RunCMake_SOURCE_DIR}/osx.cmake") + run_cmake(XcodeTbdStub) + unset(RunCMake_TEST_OPTIONS) +endif() diff --git a/Tests/RunCMake/XcodeProject/XcodeTbdStub-stdout.txt b/Tests/RunCMake/XcodeProject/XcodeTbdStub-stdout.txt new file mode 100644 index 0000000..9d9e143 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeTbdStub-stdout.txt @@ -0,0 +1 @@ +.*/libz\.tbd.* diff --git a/Tests/RunCMake/XcodeProject/XcodeTbdStub.cmake b/Tests/RunCMake/XcodeProject/XcodeTbdStub.cmake new file mode 100644 index 0000000..e83d7f3 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/XcodeTbdStub.cmake @@ -0,0 +1,2 @@ +cmake_minimum_required(VERSION 3.3) +find_package(ZLIB REQUIRED) diff --git a/Tests/RunCMake/XcodeProject/osx.cmake b/Tests/RunCMake/XcodeProject/osx.cmake new file mode 100644 index 0000000..e021fcd --- /dev/null +++ b/Tests/RunCMake/XcodeProject/osx.cmake @@ -0,0 +1,18 @@ +set(CMAKE_SYSTEM_NAME Darwin) +set(CMAKE_SYSTEM_VERSION 1) +set(UNIX True) +set(APPLE True) + +find_program(XCRUN_EXECUTABLE xcrun) +if(NOT XCRUN_EXECUTABLE) + message(FATAL_ERROR "xcrun not found") +endif() + +execute_process( + COMMAND ${XCRUN_EXECUTABLE} --sdk macosx --show-sdk-path + OUTPUT_VARIABLE OSX_SDK_PATH + OUTPUT_STRIP_TRAILING_WHITESPACE) + +set(CMAKE_OSX_SYSROOT ${OSX_SDK_PATH} CACHE PATH "Sysroot used for OSX support") + +set(CMAKE_FIND_ROOT_PATH ${OSX_SDK_PATH} CACHE PATH "Find search path root") |