Skip to content

Commit

Permalink
Merge pull request #5 from TimSimpson/update-package-names
Browse files Browse the repository at this point in the history
changes package names
  • Loading branch information
TimSimpson authored Jun 19, 2020
2 parents 4122c77 + 181757d commit 53034c8
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ osx: &osx

install:
- git clone https://github.com/TimSimpson/ci-land.git ci
- pushd ci && git checkout 3f0e77a79836a194ec2e5745341919bd6b9cc2c1 && popd
- pushd ci && git checkout 4dd39c78db7cc68529a9432e1b02f8f8967d8e27 && popd
- ./ci/cpp/conan/travis/install.sh

script:
Expand Down
60 changes: 30 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# *********************************************************************
# LP3_MAIN
# Simplifies writing game "main.cpp" files.
# Simplifies writing game "lp3-main.cpp" files.
# *********************************************************************
project(Lp3_Main CXX)
project(lp3-main CXX)
cmake_minimum_required(VERSION 3.9.0 FATAL_ERROR)
include(CMakePackageConfigHelpers)

Expand All @@ -16,18 +16,18 @@ if(using_conan)
endif()

add_library(
lp3_main
lp3-main
${CMAKE_CURRENT_SOURCE_DIR}/include/lp3/main.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/lp3/main/config.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/lp3/main/utils.hpp
${CMAKE_CURRENT_SOURCE_DIR}/src/exit.cpp)
set_target_properties(lp3_main PROPERTIES OUTPUT_NAME "Lp3_Main")
set_target_properties(lp3-main PROPERTIES OUTPUT_NAME "lp3-main")

# Mandate the use of at least C++17 by everything that uses this
target_compile_features(lp3_main PUBLIC cxx_std_17)
target_compile_features(lp3-main PUBLIC cxx_std_17)

target_include_directories(
lp3_main
lp3-main
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE src)
Expand All @@ -38,19 +38,19 @@ target_include_directories(
# of a problem with VS, but now it is, thus the disabled warnings.
if(BUILD_SHARED_LIBS)
target_compile_definitions(
lp3_main
lp3-main
PUBLIC LP3_MAIN_API_DYNAMIC
PRIVATE LP3_MAIN_API_CREATE)
if(MSVC)
target_compile_options(lp3_main PRIVATE /wd4251 /wd4275)
target_compile_options(lp3-main PRIVATE /wd4251 /wd4275)
endif()
endif()

if("${CMAKE_SYSTEM_NAME}" MATCHES "Emscripten")
target_sources(lp3_main
target_sources(lp3-main
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/js/platform.cpp)
else()
target_sources(lp3_main
target_sources(lp3-main
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/pc/platform.cpp)
endif()

Expand All @@ -61,36 +61,36 @@ endif()
install(DIRECTORY include/ DESTINATION include)

install(
TARGETS lp3_main
EXPORT Lp3_Main-targets
TARGETS lp3-main
EXPORT lp3-main-targets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
INCLUDES
DESTINATION include)

add_library(lp3::main ALIAS lp3_main)
add_library(lp3-main::lp3-main ALIAS lp3-main)
install(
EXPORT Lp3_Main-targets
FILE Lp3_Main-targets.cmake
NAMESPACE lp3::
DESTINATION lib/cmake/Lp3_Main)
EXPORT lp3-main-targets
FILE lp3-main-targets.cmake
NAMESPACE lp3-main::
DESTINATION lib/cmake/lp3-main)

file(
WRITE "${PROJECT_BINARY_DIR}/Lp3_MainConfig.cmake"
WRITE "${PROJECT_BINARY_DIR}/lp3-mainConfig.cmake"
"
include(CMakeFindDependencyMacro)
include(\"\${CMAKE_CURRENT_LIST_DIR}/Lp3_Main-targets.cmake\")
include(\"\${CMAKE_CURRENT_LIST_DIR}/lp3-main-targets.cmake\")
")

write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/Lp3_MainConfigVersion.cmake"
"${PROJECT_BINARY_DIR}/lp3-mainConfigVersion.cmake"
VERSION 1.0.1
COMPATIBILITY AnyNewerVersion)

install(FILES "${PROJECT_BINARY_DIR}/Lp3_MainConfig.cmake"
"${PROJECT_BINARY_DIR}/Lp3_MainConfigVersion.cmake"
DESTINATION lib/cmake/Lp3_Main)
install(FILES "${PROJECT_BINARY_DIR}/lp3-mainConfig.cmake"
"${PROJECT_BINARY_DIR}/lp3-mainConfigVersion.cmake"
DESTINATION lib/cmake/lp3-main)

# *********************************************************************
# Tests and Drivers / Demos
Expand All @@ -113,23 +113,23 @@ endfunction()
if(LP3_MAIN_FULL)
add_executable(ExitDemo WIN32
${CMAKE_CURRENT_SOURCE_DIR}/demos/ExitDemo.cpp)
target_link_libraries(ExitDemo lp3_main)
target_link_libraries(ExitDemo lp3-main)
make_test(ExitDemo)

add_executable(MainDemo WIN32
${CMAKE_CURRENT_SOURCE_DIR}/demos/MainDemo.cpp)
target_link_libraries(MainDemo lp3_main)
target_link_libraries(MainDemo lp3-main)

add_executable(WinConsoleTest
${CMAKE_CURRENT_SOURCE_DIR}/demos/WinConsoleTest.cpp)
target_link_libraries(WinConsoleTest lp3_main)
target_link_libraries(WinConsoleTest lp3-main)
make_test(WinConsoleTest)

if(LP3_SETUP_FOLDERS)
set_target_properties(lp3_main PROPERTIES FOLDER main)
set_target_properties(ExitDemo PROPERTIES FOLDER main)
set_target_properties(MainDemo PROPERTIES FOLDER main)
set_target_properties(WinConsoleTest PROPERTIES FOLDER main)
set_target_properties(lp3-main PROPERTIES FOLDER lp3-main)
set_target_properties(ExitDemo PROPERTIES FOLDER lp3-main)
set_target_properties(MainDemo PROPERTIES FOLDER lp3-main)
set_target_properties(WinConsoleTest PROPERTIES FOLDER lp3-main)
endif()
if(BUILD_SHARED_LIBS)
if(MSVC)
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ environment:
install:
- git clone https://github.com/TimSimpson/ci-land.git ci
- cd ci
- git checkout 3f0e77a79836a194ec2e5745341919bd6b9cc2c1
- git checkout 4dd39c78db7cc68529a9432e1b02f8f8967d8e27
- cd ..
- ci\cpp\conan\appveyor\install.bat

Expand Down
11 changes: 11 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Change Log

### 1.0.4 2020-06-19 find_package name changed

The CMake targets have changed to the following:

find_package(lp3-main)
target_link_libraries(main lp3-main::lp3-main)

I **really** wanted to use `find_package(Lp3-Main)` with the target then being `lp3::main`, but even though Conan has [dramatically increased support for matching esoteric CMake target names](https://github.com/TimSimpson/lp3-sdl/issues/5) it still can't pull this off, and wants the first part of the target (ie the part before `::`) to be identical to the argument to `find_package` (so `find_package(Lp3-Main)` had to have targets like `Lp3-Main::main`). Nuts.

For the record, I'm not sure if it's a good idea to share the prefix amongst targets brought in by `find_package` even when using nothing but CMake. Anyway it's probably not worth caring about... though man it sure is ugly.

### 1.0.3 2020-06-11 bug fix

🐞 Fixed a gross bug in PlatformLoop on Windows which triggered an assert error in debug mode (who knows what really happened in release) whenever it read the command line arguments (so, like, all the time 😬). `wcstombs_s` is a harsh mistress.
Expand Down
13 changes: 11 additions & 2 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class Lp3Main(conans.ConanFile):
name = "Lp3-Main"
version = "1.0.3"
version = "1.0.4"
license = "Zlib"
author = "Tim Simpson"
url = "https://github.com/TimSimpson/Lp3-Main"
Expand Down Expand Up @@ -53,4 +53,13 @@ def package(self):
# self.copy("Lp3_Main-config*.cmake", dst="lib/cmake", keep_path=False)

def package_info(self):
self.cpp_info.libs = ["lp3_core"]
self.cpp_info.name = "lp3-main"
self.cpp_info.libs = [ "lp3-main" ]
# self.cpp_info.libs = ["lp3-main"]
# # self.cpp_info.names["cmake_find_package"] = "Lp3-Main"
# # self.cpp_info.names["cmake_find_package_multi"] = "Lp3"
# self.cpp_info.components["main"].names["cmake"] = "main"
# self.cpp_info.components["main"].names["cmake_find_package"] = "main"
# self.cpp_info.components["main"].names["cmake_find_package_multi"] = "main"
# self.cpp_info.components["main"].includedirs = ["include"]
# self.cpp_info.components["main"].libs = ["lp3-main"]
6 changes: 2 additions & 4 deletions test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@ project(test_package)

set(CMAKE_CXX_STANDARD 17)

include(${CMAKE_BINARY_DIR}/conan_paths.cmake)

find_package(Lp3_Main CONFIG REQUIRED)
find_package(lp3-main REQUIRED)

add_executable(main_test ${CMAKE_CURRENT_SOURCE_DIR}/main_test.cpp)
target_link_libraries(main_test PUBLIC lp3::lp3_main)
target_link_libraries(main_test PUBLIC lp3-main::lp3-main)
# add_test(main_test main_test)
2 changes: 1 addition & 1 deletion test_package/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class TestPackage(conans.ConanFile):

generators = "cmake_paths"
generators = "cmake_find_package"
settings = "os", "compiler", "build_type", "arch"

def build(self):
Expand Down

0 comments on commit 53034c8

Please sign in to comment.