Skip to content

cnruby/w3h1_cmake

 
 

Repository files navigation

Hello, $PATH!

Creating a Symbolic Link for a Library



@Gitter :gitter.im/cnruby
Code ID: basic_127
Code Name: Hello, $PATH!

Youtube Video

TABLE of CONTENTS

About The Project

About The Project

Requirements

Install The Library gettext

# For MacOS 10.11+
brew install gettext
# For Ubuntu 20.04+
sudo apt-get install -y gettext

Get The Code with Shell Commands

#<!-- markdown-exec(cmd:cat ../get_project.sh) -->#!/bin/bash
# ./get_project.sh <PROJECT_ID>
# ./get_project.sh basic_127
#
PROJECT_HOME=$HOME/Documents/dev/cpp-ws/$1
git clone https://github.com/cnruby/w3h1_cmake.git $PROJECT_HOME
cd $PROJECT_HOME && git checkout $1
code $PROJECT_HOME
#<!-- /markdown-exec -->

Demonstrate Creating a Symbolic Link for a Library

The Structure of Project

_image

_image

The Process's Structure of Project "basic_121"

_image

The Process's Structure of Project "basic_127"

The Codes of Project

#<!-- markdown-exec(cmd:cat shell/ln_gettext_short.sh) -->#!/bin/sh
SOURCE_DIR=/usr/local/opt/gettext
DESTN_DIR=/usr/local
ln -s $SOURCE_DIR/include/libintl.h $DESTN_DIR/include/libintl.h
ln -s $SOURCE_DIR/lib/libintl.dylib $DESTN_DIR/lib/libintl.dylib
ln -s $SOURCE_DIR/lib/libintl.a $DESTN_DIR/lib/libintl.a
#<!-- /markdown-exec -->

The Shell Codes of Project

#<!-- markdown-exec(cmd:cat src/CMakeLists.txt) -->#
add_executable(
  main_127 main.cxx
)

target_include_directories(
  main_127
  PRIVATE ${_PROJECT_CONFIG_DIR}
)

# link against the library
target_link_libraries(
  main_127
  PRIVATE Intl
)
#<!-- /markdown-exec -->

The Listfile of Folder 'src'

#<!-- markdown-exec(cmd:cat cmake/GetLibintl.cmake) -->#
message("\nFROM cmake/GetLibintl.txt")
# find a library 'libintl'
find_package(Intl REQUIRED)

# check if Intl was found
if(Intl_FOUND)
  message(STATUS "Intl found\t\t= ${Intl_FOUND}")
  message(STATUS "Intl_INCLUDE_DIRS\t= ${Intl_INCLUDE_DIRS}")
  message(STATUS "Intl_LIBRARIES\t= ${Intl_LIBRARIES}")
else()
  message(FATAL_ERROR "Cannot find Intl")
endif()
message("FROM cmake/GetLibintl.txt")
#<!-- /markdown-exec -->

The File 'GetLibintl.cmake' of Folder 'cmake'

_image

Final Summary

感谢大家观看!

@Gitter: gitter.im/cnruby

@Github: github.com/cnruby

@Twitter: twitter.com/cnruby

@Blogspot: cnruby.blogspot.com

References

The Structures of Project

#<!-- markdown-exec(cmd:cat docs/output/tree.txt) -->#
.
├── cmake
│  ├── CMakeLists.txt
│  └── config.h.in
├── CMakeLists.txt
├── config
│  └── config.hxx
└── src
   ├── CMakeLists.txt
    └── main.cxx
#<!-- /markdown-exec -->

The Folder's Structure