Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve issue #526 #557

Merged
merged 1 commit into from
Jun 14, 2017
Merged

Resolve issue #526 #557

merged 1 commit into from
Jun 14, 2017

Conversation

jasjuang
Copy link
Contributor

@jasjuang jasjuang commented Jun 2, 2017

With this addition of cmake export, users can now use find_package(tinyxml2) in config mode, meaning no more Findtinyxml2.cmake is needed!!

To demonstrate the convenience of this feature, first clone, build, and install tinyxml2

git clone https://github.com/jasjuang/tinyxml2
cd tinyxml2
mkdir build
cd build
cmake ..
sudo make install

Now go to your own repo and then create a CMakeLists of your own that looks something like

cmake_minimum_required(VERSION 3.5)
project(tinyxml2Example)

set(PROJECT_SRCS
${PROJECT_SOURCE_DIR}/tinyxml2Example.cpp
)

find_package( tinyxml2 REQUIRED )

add_executable(${PROJECT_NAME} ${PROJECT_SRCS})

target_link_libraries(${PROJECT_NAME} tinyxml2)

That will just work! A step by step to reproduce this will be something like

mkdir mytestrepo
cd mytesttrepo
touch CMakeLists.txt 
# use your favorite text editor to copy paste the above in
touch tinyxml2Example.cpp
# use your favorite text editor to add in some tinyxml2 code
mkdir build
cd build
cmake ..
make

endif()

# export targets for find_package config mode
export(TARGETS tinyxml2
FILE ${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}Targets.cmake)
Copy link

Choose a reason for hiding this comment

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

As I understand, the Export installation path should be LIBDIR/cmake/PROJECT_NAME

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@comargo which I did in line 166~171. This line just export the targets locally and not installing yet

Copy link

Choose a reason for hiding this comment

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

Ah! Sorry... I missed the name of variable...

@jasjuang
Copy link
Contributor Author

@leethomason Could you merge this and make a release? This feature is necessary for integration to vcpkg. Thanks

@leethomason leethomason merged commit 7ce75bc into leethomason:master Jun 14, 2017
@jasjuang
Copy link
Contributor Author

@leethomason Could you make a release? I will submit a pull request to vcpkg once you make a release, thanks!

@leethomason
Copy link
Owner

There's another PR going in, and then I'll do a release.

@jasjuang
Copy link
Contributor Author

@leethomason Thanks for the release. I submitted a PR to vcpkg and once it's merged Windows users will be able to build and install tinyxml2 by simply typing vcpkg install tinyxml2!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants